all repos — nixfiles @ 67dec02ddcfae528dd23696cb7d51746dbadeaf6

System and user configuration, managed by nix and home-manager

Simplify home-manager setup with flake-utils
Alan Pearce alan@alanpearce.eu
Tue, 09 Apr 2024 22:08:33 +0200
commit

67dec02ddcfae528dd23696cb7d51746dbadeaf6

parent

8d94bdf8d7b58d91e11623d96c16daf1b6d82367

3 files changed, 63 insertions(+), 28 deletions(-)

jump to
M flake.lockflake.lock
@@ -156,7 +156,8 @@ "home-manager": "home-manager",         "nix-index-database": "nix-index-database",
         "nixos-hardware": "nixos-hardware",
         "nixpkgs": "nixpkgs",
-        "secrets": "secrets"
+        "secrets": "secrets",
+        "utils": "utils"
       }
     },
     "secrets": {
@@ -187,6 +188,39 @@ },       "original": {
         "owner": "nix-systems",
         "repo": "default",
+        "type": "github"
+      }
+    },
+    "systems_2": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
+    "utils": {
+      "inputs": {
+        "systems": "systems_2"
+      },
+      "locked": {
+        "lastModified": 1710146030,
+        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
         "type": "github"
       }
     }
M flake.nixflake.nix
@@ -13,26 +13,31 @@ emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";     secrets = {
       flake = false;
     };
+    utils.url = "github:numtide/flake-utils";
   };
 
   outputs =
+    inputs@
     { self
+    , utils
+    , nixpkgs
+    , nixos-hardware
+    , home-manager
     , darwin
-    , emacs-overlay
-    , home-manager
-    , nixpkgs
     , nix-index-database
-    , nixos-hardware
     , secrets
+    , emacs-overlay
     , ...
-    } @ attrs:
+    }:
     let
-      darwinSystem = "aarch64-darwin";
-      darwinPkgs = nixpkgs.legacyPackages.${darwinSystem};
-      nixosSystem = "x86_64-linux";
-      nixosPkgs = nixpkgs.legacyPackages.${nixosSystem};
-      aarch64LinuxSystem = "aarch64-linux";
-      aarch64LinuxPackages = nixpkgs.legacyPackages.${aarch64LinuxSystem};
+      mkHomeConfiguration = { modules, system }: home-manager.lib.homeManagerConfiguration {
+        pkgs = import nixpkgs { inherit system; };
+
+        inherit modules;
+        extraSpecialArgs = {
+          inherit inputs system;
+        };
+      };
     in
     {
       nixosConfigurations.prefect = nixpkgs.lib.nixosSystem {
@@ -48,16 +53,15 @@ common-gpu-nvidia-nonprime         ]);
       };
       nixosConfigurations.nanopi = nixpkgs.lib.nixosSystem {
-        system = aarch64LinuxSystem;
+        system = utils.lib.system.aarch64-linux;
         modules = [ ./nanopi.nix ];
       };
       darwinConfigurations.mba = darwin.lib.darwinSystem {
-        system = darwinSystem;
+        system = utils.lib.system.aarch64-darwin;
         modules = [ ./system/mba.nix ];
       };
-      homeConfigurations."alan@mba" = home-manager.lib.homeManagerConfiguration {
-        pkgs = darwinPkgs;
-        extraSpecialArgs = { inherit attrs; };
+      homeConfigurations."alan@mba" = mkHomeConfiguration {
+        system = utils.lib.system.aarch64-darwin;
         modules = [
           ./user/mba.nix
           nix-index-database.hmModules.nix-index
@@ -66,9 +70,8 @@ (secrets + "/ssh.nix")           ({ nixpkgs.overlays = [ emacs-overlay.overlay ]; })
         ];
       };
-      homeConfigurations."alan@prefect" = home-manager.lib.homeManagerConfiguration {
-        pkgs = nixosPkgs;
-        extraSpecialArgs = { inherit attrs; };
+      homeConfigurations."alan@prefect" = mkHomeConfiguration {
+        system = utils.lib.system.x86_64-linux;
         modules = [
           ./user/prefect.nix
           nix-index-database.hmModules.nix-index
@@ -77,18 +80,16 @@ (secrets + "/ssh.nix")           ({ nixpkgs.overlays = [ emacs-overlay.overlay ]; })
         ];
       };
-      homeConfigurations."alan@nanopi" = home-manager.lib.homeManagerConfiguration {
-        pkgs = aarch64LinuxPackages;
-        extraSpecialArgs = { inherit attrs; };
+      homeConfigurations."alan@nanopi" = mkHomeConfiguration {
+        system = utils.lib.system.aarch64-linux;
         modules = [
           ./user/nanopi.nix
           nix-index-database.hmModules.nix-index
           (secrets + "/default.nix")
         ];
       };
-      homeConfigurations."alan@pappel" = home-manager.lib.homeManagerConfiguration {
-        pkgs = nixosPkgs;
-        extraSpecialArgs = { inherit attrs; };
+      homeConfigurations."alan@linde" = mkHomeConfiguration {
+        system = utils.lib.system.aarch64-linux;
         modules = [
           ./user/server.nix
           nix-index-database.hmModules.nix-index
M user/settings/pin.nixuser/settings/pin.nix
@@ -1,6 +1,6 @@-{ attrs, ... }:
+{ inputs, ... }:
 let
-  inherit (attrs) nixpkgs;
+  inherit (inputs) nixpkgs;
 in
 {
   nix = {