diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-01-22 13:02:57 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-01-22 13:02:57 +0900 |
| commit | ad442e140c643eb3a80f5d4f59aa00b21c00888f (patch) | |
| tree | ec23c74150656e9d4ead72bb607377c4196f72b1 /flake.nix | |
| parent | 9d03982f63be8baa73f1072c51fe8fa15fcf6c20 (diff) | |
| download | dotfiles-ad442e140c643eb3a80f5d4f59aa00b21c00888f.tar.gz dotfiles-ad442e140c643eb3a80f5d4f59aa00b21c00888f.tar.zst dotfiles-ad442e140c643eb3a80f5d4f59aa00b21c00888f.zip | |
nix: refactor flake.nix by flake-utils
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 66 |
1 files changed, 36 insertions, 30 deletions
@@ -28,40 +28,46 @@ ... }: let - readJSON = p: builtins.fromJSON (builtins.readFile p); - machines = [ - (readJSON ./mitamae/node.akashi.json) - (readJSON ./mitamae/node.hotaru.json) - (readJSON ./mitamae/node.pc168.json) - ]; - mkHomeConfiguration = - { - system, - env, - ... - }: - home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { + eachDefaultSystem = + f: + flake-utils.lib.eachDefaultSystem ( + system: + f { inherit system; - config.allowUnfree = true; - }; - extraSpecialArgs = { inherit env; }; - modules = [ - ./home-manager/home.nix - ]; - }; + pkgs = import nixpkgs { inherit system; }; + } + ); in - flake-utils.lib.eachDefaultSystem (system: { - formatter = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style; - }) + eachDefaultSystem ( + { system, pkgs }: + { + formatter = pkgs.nixfmt-rfc-style; + } + ) // { homeConfigurations = ( - builtins.listToAttrs ( - builtins.map (machine: { - name = machine.name; - value = mkHomeConfiguration machine.flake; - }) machines - ) + let + readJSON = p: builtins.fromJSON (builtins.readFile p); + mkHomeConfiguration = + { + system, + env, + ... + }: + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { inherit system; }; + extraSpecialArgs = { inherit env; }; + modules = [ + ./home-manager/home.nix + ]; + }; + mkHomeConfigurationFromJSON = p: mkHomeConfiguration (readJSON p).flake; + in + { + akashi = mkHomeConfigurationFromJSON ./mitamae/node.akashi.json; + hotaru = mkHomeConfigurationFromJSON ./mitamae/node.hotaru.json; + pc168 = mkHomeConfigurationFromJSON ./mitamae/node.pc168.json; + } ); }; } |
