diff --git a/flake.lock b/flake.lock index 120e32c..569fe4c 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,20 @@ "type": "github" } }, + "hosts": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "narHash": "sha256-LbajVWkqSpZt2SW7tGqxIn391hCT02AyokxFuNyA/4w=", + "path": "../fudo-hosts", + "type": "path" + }, + "original": { + "path": "../fudo-hosts", + "type": "path" + } + }, "nixpkgs": { "locked": { "lastModified": 1628427351, @@ -36,10 +50,26 @@ "type": "indirect" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1628427351, + "narHash": "sha256-WuZUIQ07AvRw+T9wvQ3qFf8MXmKZ+ktZz9drNgWXDbs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "348bc5de8bca09c624f5c4975f538684da4713d2", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05", + "type": "indirect" + } + }, "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "hosts": "hosts", + "nixpkgs": "nixpkgs_2" } } }, diff --git a/flake.nix b/flake.nix index 7810e63..803bf4f 100644 --- a/flake.nix +++ b/flake.nix @@ -3,24 +3,17 @@ inputs = { nixpkgs.url = "nixpkgs/nixos-21.05"; + + hosts.url = "path:../fudo-hosts"; + home-manager.url = "github:nix-community/home-manager/release-21.05"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { nixpkgs, home-manager, ... }: + outputs = { nixpkgs, hosts, home-manager, ... }: let - hosts-path = ./config/hosts; - lib = nixpkgs.lib; - is-nix-file = filename: type: (builtins.match ".+.nix$" filename) != null; - is-regular-file = filename: type: type == "regular" || type == "link"; - hostname-from-file = filename: - builtins.replaceStrings [ ".nix" ] [ "" ] filename; - hosts = map hostname-from-file (lib.attrNames (lib.filterAttrs is-nix-file - (lib.filterAttrs is-regular-file (builtins.readDir hosts-path)))); - hostsOpts = lib.listToAttrs (hostname: - lib.nameValuePair hostname (import hosts-path + "/${hostname}.nix")); - pkgs = import nixpkgs { }; + lib = nixpkgs.lib; in { nixConfigurations = lib.mapAttrs (hostname: hostOpts: @@ -34,6 +27,6 @@ include-secrets = true; }) ]; - }) hostsOpts; + }) hosts.host-configs; }; }