From 971c48da072b26bda8bb9b5f6ccda6148b169cd6 Mon Sep 17 00:00:00 2001 From: schererleander Date: Fri, 2 May 2025 13:54:33 +0200 Subject: setup nix-darwin --- flake.lock | 39 +++++++++++++++++++++++++++++++++++++++ flake.nix | 35 ++++++++++++++++++++++++++--------- hosts/darwin/configuration.nix | 15 +++++++++++++++ hosts/darwin/home.nix | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 hosts/darwin/configuration.nix create mode 100644 hosts/darwin/home.nix diff --git a/flake.lock b/flake.lock index af9f1a9..2671cc7 100644 --- a/flake.lock +++ b/flake.lock @@ -35,6 +35,27 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743127615, + "narHash": "sha256-+sMGqywrSr50BGMLMeY789mSrzjkoxZiu61eWjYS/8o=", + "owner": "nix-darwin", + "repo": "nix-darwin", + "rev": "fc843893cecc1838a59713ee3e50e9e7edc6207c", + "type": "github" + }, + "original": { + "owner": "nix-darwin", + "ref": "nix-darwin-24.11", + "repo": "nix-darwin", + "type": "github" + } + }, "nixcord": { "inputs": { "flake-compat": "flake-compat", @@ -72,6 +93,22 @@ "type": "github" } }, + "nixpkgs-darwin": { + "locked": { + "lastModified": 1746163478, + "narHash": "sha256-YO8tVX1TbRP/Rc2dWxNr+f+rLlJ80bilKOnsXaeLBDg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c81a66344a0fa9ae018a831c18b9dfec3daa6cb6", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-24.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1745868005, @@ -91,8 +128,10 @@ "root": { "inputs": { "home-manager": "home-manager", + "nix-darwin": "nix-darwin", "nixcord": "nixcord", "nixpkgs": "nixpkgs_2", + "nixpkgs-darwin": "nixpkgs-darwin", "spicetify-nix": "spicetify-nix" } }, diff --git a/flake.nix b/flake.nix index ff81693..29cf5aa 100644 --- a/flake.nix +++ b/flake.nix @@ -3,25 +3,29 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.11-darwin"; + + nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-24.11"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + home-manager.url = "github:nix-community/home-manager/release-24.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; - + spicetify-nix.url = "github:Gerg-L/spicetify-nix"; spicetify-nix.inputs.nixpkgs.follows = "nixpkgs"; nixcord.url = "github:kaylorben/nixcord"; }; - outputs = { nixpkgs, home-manager, ... } @ inputs: let - system = "x86_64-linux"; - username = "leander"; + outputs = { nixpkgs, nix-darwin, home-manager, ... } @ inputs: let + linux-system = "x86_64-linux"; + darwin-system = "aarch64-darwin"; + username = "schererleander"; email = "leander@schererleander.de"; desktop = "nixos"; - pkgs = import nixpkgs { inherit system; }; in { - nixosConfigurations = { - nixos = nixpkgs.lib.nixosSystem { - inherit system; + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = linux-system; specialArgs = { inherit inputs; }; modules = [ ./hosts/nixos/configuration.nix @@ -38,7 +42,20 @@ } ]; }; - }; + darwinConfigurations."MacBook-Air" = nix-darwin.lib.darwinSystem { + system = darwin-system; + specialArgs = { inherit inputs username; }; + modules = [ + ./hosts/darwin/configuration.nix + + home-manager.darwinModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit inputs; }; + home-manager.users.${username} = import ./hosts/darwin/home.nix; + } + ]; + }; }; } diff --git a/hosts/darwin/configuration.nix b/hosts/darwin/configuration.nix new file mode 100644 index 0000000..fc1ba38 --- /dev/null +++ b/hosts/darwin/configuration.nix @@ -0,0 +1,15 @@ +{ config, pkgs, lib, ...}: + +{ + services.nix-daemon.enable = true; + programs.zsh.enable = true; + + users.users.schererleander = { + home = "/Users/schererleander"; + shell = pkgs.zsh; + }; + + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.config.allowUnfree = true; + system.stateVersion = 5; +} diff --git a/hosts/darwin/home.nix b/hosts/darwin/home.nix new file mode 100644 index 0000000..b925ef5 --- /dev/null +++ b/hosts/darwin/home.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, inputs, ...}: + +{ + imports = [ + inputs.spicetify-nix.homeManagerModules.spicetify + ../../modules + ]; + + home.username = "schererleander"; + home.homeDirectory = "/Users/schererleander"; + + home.packages = with pkgs; [ + htop + ffmpeg + pfetch + + #dev + gcc + lua-language-server + pyright + jdk + nodejs + + obsidian + + ]; + + zsh.enable = true; + tmux.enable = true; + git.enable = true; + neovim.enable = true; + + chromium.enable = true; + vscode.enable = true; + + home.stateVersion = "24.11"; +} -- cgit v1.3.1