From fbbe869550e06e9a531da1e1ce7687f45f3c201b Mon Sep 17 00:00:00 2001 From: Jan-Bulthuis Date: Sun, 18 May 2025 15:00:51 +0200 Subject: [PATCH] Reworked glue input --- flake.lock | 93 ++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 6 ++- glue/lib/default.nix | 38 ++++++++++-------- 3 files changed, 120 insertions(+), 17 deletions(-) diff --git a/flake.lock b/flake.lock index 66cce98..e19eb2c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,39 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "glue": { "locked": { "path": "./glue", @@ -31,6 +65,48 @@ "type": "github" } }, + "nix-minecraft": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747526922, + "narHash": "sha256-NmBP0W4RJ8NTkeaMKy/NNzMBIQDa8n161Igbu7zWM2E=", + "owner": "Jan-Bulthuis", + "repo": "nix-minecraft", + "rev": "566b5218ff51d80da60873fe3b5930b8da12091c", + "type": "github" + }, + "original": { + "owner": "Jan-Bulthuis", + "repo": "nix-minecraft", + "type": "github" + } + }, + "nix-modpack": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747559249, + "narHash": "sha256-+ygKEGMVcXNklO4RDYSd5XzydDmQOZWcOcxYZf/PH1U=", + "owner": "Jan-Bulthuis", + "repo": "nix-modpack", + "rev": "a093625c2847afc3ef257513161c7fe318c6be1c", + "type": "github" + }, + "original": { + "owner": "Jan-Bulthuis", + "repo": "nix-modpack", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1746576598, @@ -51,8 +127,25 @@ "inputs": { "glue": "glue", "home-manager": "home-manager", + "nix-minecraft": "nix-minecraft", + "nix-modpack": "nix-modpack", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 30673e7..e6871b3 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,11 @@ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nix-minecraft.url = "github:Jan-Bulthuis/nix-minecraft"; + nix-minecraft.inputs.nixpkgs.follows = "nixpkgs"; + nix-modpack.url = "github:Jan-Bulthuis/nix-modpack"; + nix-modpack.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs: inputs.glue { inherit inputs; }; + outputs = inputs: inputs.glue inputs; } diff --git a/glue/lib/default.nix b/glue/lib/default.nix index e0415cc..108a7c4 100644 --- a/glue/lib/default.nix +++ b/glue/lib/default.nix @@ -2,10 +2,7 @@ let mkGlue = - { - inputs, - ... - }: + inputs: let flake = inputs.self; nixpkgs = inputs.nixpkgs; @@ -50,12 +47,7 @@ let in fn (entries // recursedEntries); - systems = [ - "x86_64-linux" - "aarch64-linux" - ]; - - eachSystem = fn: lib.genAttrs systems fn; + eachSystem = fn: lib.genAttrs lib.systems.flakeExposed fn; systemArgs = eachSystem (system: { pkgs = ( @@ -103,17 +95,31 @@ let ); nixosModules = collectModules "${flake}/modules/nixos"; + inputNixosModules = lib.map (flake: flake.outputs.nixosModules.default) ( + lib.filter (flake: lib.hasAttrByPath [ "outputs" "nixosModules" "default" ] flake) ( + lib.attrValues inputs + ) + ); homeModules = collectModules "${flake}/modules/home"; + inputHomeModules = lib.map (flake: flake.outputs.homeManagerModules.default) ( + lib.filter (flake: lib.hasAttrByPath [ "outputs" "homeManagerModules" "default" ] flake) ( + lib.attrValues inputs + ) + ); + + inputOverlays = lib.map (flake: flake.outputs.overlays.default) ( + lib.filter (flake: lib.hasAttrByPath [ "outputs" "overlays" "default" ] flake) ( + lib.attrValues inputs + ) + ); overlayModule = { ... }: { - nixpkgs.overlays = [ overlay ]; + nixpkgs.overlays = [ overlay ] ++ inputOverlays; }; - homeManager = inputs.home-manager.nixosModules.home-manager; - nixosConfigurations = importDir "${flake}/hosts" ( attrs: lib.mapAttrs ( @@ -139,7 +145,7 @@ let usersModule = { ... }: { - home-manager.sharedModules = homeModules; + home-manager.sharedModules = homeModules ++ inputHomeModules; home-manager.useUserPackages = false; # TODO: See if this should be changed to true? home-manager.useGlobalPkgs = true; home-manager.users = homesConfiguration; @@ -151,9 +157,9 @@ let systemPath overlayModule usersModule - homeManager ] - ++ nixosModules; + ++ nixosModules + ++ inputNixosModules; } ) (lib.attrsets.filterAttrs (name: entry: entry.type == "directory") attrs) );