From 3aeeb69c2b977963e272ab341bbe9da7192df09e Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Thu, 5 Sep 2024 00:30:25 +0100 Subject: [PATCH] nix-darwin: add macbook --- .../jakehillion-mba-m2-15/configuration.nix | 24 ++++ flake.lock | 13 ++- flake.nix | 105 +++++++++++------- 3 files changed, 95 insertions(+), 47 deletions(-) create mode 100644 darwin/jakehillion-mba-m2-15/configuration.nix diff --git a/darwin/jakehillion-mba-m2-15/configuration.nix b/darwin/jakehillion-mba-m2-15/configuration.nix new file mode 100644 index 0000000..892793d --- /dev/null +++ b/darwin/jakehillion-mba-m2-15/configuration.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: + +{ + config = { + system.stateVersion = 4; + + networking.hostName = "jakehillion-mba-m2-15"; + + nix = { + useDaemon = true; + }; + + programs.zsh.enable = true; + + security.pam.enableSudoTouchIdAuth = true; + + environment.systemPackages = with pkgs; [ + htop + mosh + neovim + nix + ]; + }; +} diff --git a/flake.lock b/flake.lock index 1665020..0021f54 100644 --- a/flake.lock +++ b/flake.lock @@ -2,7 +2,9 @@ "nodes": { "agenix": { "inputs": { - "darwin": "darwin", + "darwin": [ + "darwin" + ], "home-manager": [ "home-manager" ], @@ -28,21 +30,19 @@ "darwin": { "inputs": { "nixpkgs": [ - "agenix", "nixpkgs" ] }, "locked": { - "lastModified": 1700795494, - "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", + "lastModified": 1725189302, + "narHash": "sha256-IhXok/kwQqtusPsoguQLCHA+h6gKvgdCrkhIaN+kByA=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", + "rev": "7c4b53a7d9f3a3df902b3fddf2ae245ef20ebcda", "type": "github" }, "original": { "owner": "lnl7", - "ref": "master", "repo": "nix-darwin", "type": "github" } @@ -172,6 +172,7 @@ "root": { "inputs": { "agenix": "agenix", + "darwin": "darwin", "flake-utils": "flake-utils", "home-manager": "home-manager", "home-manager-unstable": "home-manager-unstable", diff --git a/flake.nix b/flake.nix index eac1b03..097e90f 100644 --- a/flake.nix +++ b/flake.nix @@ -7,8 +7,12 @@ flake-utils.url = "github:numtide/flake-utils"; + darwin.url = "github:lnl7/nix-darwin"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; + agenix.url = "github:ryantm/agenix"; agenix.inputs.nixpkgs.follows = "nixpkgs"; + agenix.inputs.darwin.follows = "darwin"; agenix.inputs.home-manager.follows = "home-manager"; home-manager.url = "github:nix-community/home-manager/release-24.05"; @@ -21,48 +25,67 @@ description = "Hillion Nix flake"; - outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-utils, agenix, home-manager, home-manager-unstable, impermanence, ... }@inputs: { - nixosConfigurations = - let - fqdns = builtins.attrNames (builtins.readDir ./hosts); - getSystemOverlays = system: nixpkgsConfig: [ - (final: prev: { - unstable = nixpkgs-unstable.legacyPackages.${prev.system}; - "storj" = final.callPackage ./pkgs/storj.nix { }; - }) - ]; - mkHost = fqdn: - let - system = builtins.readFile ./hosts/${fqdn}/system; - func = if builtins.pathExists ./hosts/${fqdn}/unstable then nixpkgs-unstable.lib.nixosSystem else nixpkgs.lib.nixosSystem; - home-manager-pick = if builtins.pathExists ./hosts/${fqdn}/unstable then home-manager-unstable else home-manager; - in - func { - inherit system; - specialArgs = inputs; - modules = [ - ./hosts/${fqdn}/default.nix - ./modules/default.nix + outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-utils, agenix, home-manager, home-manager-unstable, darwin, impermanence, ... }@inputs: + let + getSystemOverlays = system: nixpkgsConfig: [ + (final: prev: { + unstable = nixpkgs-unstable.legacyPackages.${prev.system}; + "storj" = final.callPackage ./pkgs/storj.nix { }; + }) + ]; + in + { + nixosConfigurations = + let + fqdns = builtins.attrNames (builtins.readDir ./hosts); + mkHost = fqdn: + let + system = builtins.readFile ./hosts/${fqdn}/system; + func = if builtins.pathExists ./hosts/${fqdn}/unstable then nixpkgs-unstable.lib.nixosSystem else nixpkgs.lib.nixosSystem; + home-manager-pick = if builtins.pathExists ./hosts/${fqdn}/unstable then home-manager-unstable else home-manager; + in + func { + inherit system; + specialArgs = inputs; + modules = [ + ./hosts/${fqdn}/default.nix + ./modules/default.nix - agenix.nixosModules.default - impermanence.nixosModules.impermanence + agenix.nixosModules.default + impermanence.nixosModules.impermanence - home-manager-pick.nixosModules.default - { - home-manager.sharedModules = [ - impermanence.nixosModules.home-manager.impermanence - ]; - } + home-manager-pick.nixosModules.default + { + home-manager.sharedModules = [ + impermanence.nixosModules.home-manager.impermanence + ]; + } - ({ config, ... }: { - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - nixpkgs.overlays = getSystemOverlays config.nixpkgs.hostPlatform.system config.nixpkgs.config; - }) - ]; - }; - in - nixpkgs.lib.genAttrs fqdns mkHost; - } // flake-utils.lib.eachDefaultSystem (system: { - formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; - }); + ({ config, ... }: { + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + nixpkgs.overlays = getSystemOverlays config.nixpkgs.hostPlatform.system config.nixpkgs.config; + }) + ]; + }; + in + nixpkgs.lib.genAttrs fqdns mkHost; + + darwinConfigurations = { + jakehillion-mba-m2-15 = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = inputs; + + modules = [ + ./darwin/jakehillion-mba-m2-15/configuration.nix + + ({ config, ... }: { + nixpkgs.overlays = getSystemOverlays "aarch64-darwin" config.nixpkgs.config; + }) + ]; + }; + }; + + } // flake-utils.lib.eachDefaultSystem (system: { + formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + }); }