diff --git a/default.nix b/default.nix index 5740f6a3..7fecce2b 100644 --- a/default.nix +++ b/default.nix @@ -1,122 +1,7 @@ -{ self, utils, nixpkgs, darwin, home-manager, ragenix, scalpel, mach-nix, arcexprs, ... }@inputs: let - tree = (inputs.tree.tree { - inherit inputs; - folder = ./.; - config = { - "/" = { - excludes = [ - "flake" - "default" - ]; - }; - "nixos/modules" = { - functor = { - enable = true; - external = with (import (arcexprs + "/modules")).nixos; [ - base16 - base16-shared - ]; - }; - }; - "home/modules" = { - functor = { - enable = true; - external = with (import (arcexprs + "/modules")).home-manager; [ - base16 - base16-shared - ]; - }; - }; - "home".evaluateDefault = true; - "home/*" = { - functor.enable = true; - }; - }; - }).impure; - lib = inputs.nixpkgs.lib; - inherit (lib.attrsets) mapAttrs; - inherit (lib.lists) singleton; -in utils.lib.mkFlake { - inherit self inputs; - supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; - channelsConfig.allowUnfree = true; - - hostDefaults = { - system = "x86_64-linux"; - extraArgs = { - inherit inputs tree; - }; - }; - - hosts = let - outputForSystem = system: { - "x86_64-linux" = "nixosConfigurations"; - "aarch64-darwin" = "darwinConfigurations"; - }.${system}; - builderForSystem = system: { - "x86_64-linux" = nixpkgs.lib.nixosSystem; - "aarch64-darwin" = darwin.lib.darwinSystem; - }.${system}; - modulesForSystem = system: { - "x86_64-linux" = [ - home-manager.nixosModules.home-manager - ragenix.nixosModules.age - tree.nixos.modules - ]; - "aarch64-darwin" = [ - home-manager.darwinModules.home-manager - ragenix.nixosModules.age - tree.darwin.modules - ]; - }.${system}; - mapSystem = system: name: path: { - inherit system; - output = outputForSystem system; - builder = builderForSystem system; - modules = (modulesForSystem system) ++ [ - path - ]; - extraArgs = { - machine = name; - }; - }; - in mapAttrs (mapSystem "x86_64-linux") tree.nixos.systems - // mapAttrs (mapSystem "aarch64-darwin") tree.darwin.systems; - - outputsBuilder = channels: { - nixosConfigurations = mapAttrs(_: sys: sys.extendModules { - modules = [ scalpel.nixosModule ]; - specialArgs = { - prev = sys; - }; - }) self.nixosConfigurations; - - homeManagerConfigurations = mapAttrs (name: path: home-manager.lib.homeManagerConfiguration { - pkgs = channels.nixpkgs; - extraSpecialArgs = { - inherit inputs tree; - machine = name; - }; - modules = [ - ({ config, ... }: { - home = { - username = "kat"; - stateVersion = "22.11"; - homeDirectory = "/home/kat"; - }; - }) - path - ]; - }) tree.home; - - inherit tree; - }; - - devShells = { - "python" = mach-nix.mkPythonShell { - python = "python310"; - requirements = '' - ''; - }; - }; -} +let + inputs = import ./inputs.nix; + self = import ./outputs.nix ({ + inherit self inputs; + system = builtins.currentSystem; + } // inputs); +in self diff --git a/flake.lock b/flake.lock index 8f3b1a75..bbfc80b7 100644 --- a/flake.lock +++ b/flake.lock @@ -24,11 +24,11 @@ "arcexprs": { "flake": false, "locked": { - "lastModified": 1669933794, - "narHash": "sha256-+7kYj0AhffjlrLXksTmCfcovRqDrBOF9TZA2jSlsfws=", + "lastModified": 1670140114, + "narHash": "sha256-Z8lmLwKTf171WYH8EMko57VtobF8DgPtKL3ioXBlKP4=", "owner": "arcnmx", "repo": "nixexprs", - "rev": "1adfd2810dd37e78ee98e5cd18afe2e87d4bbe38", + "rev": "be538181c1937c11d4ad4a0b4da203169f150be2", "type": "github" }, "original": { @@ -74,6 +74,22 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1644229661, @@ -97,11 +113,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1670058827, - "narHash": "sha256-T+yyncPpZWeIkFrG/Cgj21iopULY3BZGWIhcT5ZmCgM=", + "lastModified": 1670163996, + "narHash": "sha256-6vbu9Wmh1Ov0VgkWuLAazQ/crzohdZ8jnQp87pDsy7s=", "owner": "nix-community", "repo": "home-manager", - "rev": "eb3598cf44aa10f2a16fe38488a102c0f474d766", + "rev": "90b0e5f440160f54cb4f1f08372e1be554e10873", "type": "github" }, "original": { @@ -137,11 +153,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1669969257, - "narHash": "sha256-mOS13sK3v+kfgP+1Mh56ohiG8uVhLHAo7m/q9kqAehc=", + "lastModified": 1670064435, + "narHash": "sha256-+ELoY30UN+Pl3Yn7RWRPabykwebsVK/kYE9JsIsUMxQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b72b8b94cf0c012b0252a9100a636cad69696666", + "rev": "61a8a98e6d557e6dd7ed0cdb54c3a3e3bbc5e25c", "type": "github" }, "original": { @@ -197,6 +213,7 @@ "arcexprs": "arcexprs", "darwin": "darwin", "empty": "empty", + "flake-compat": "flake-compat", "home-manager": "home-manager", "mach-nix": "mach-nix", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 8e8fc5d2..c7c3fd40 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,10 @@ { description = "kat's personal system flakes"; inputs = { + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; empty.url = "github:input-output-hk/empty-flake"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager = { @@ -45,5 +49,5 @@ flake = false; }; }; - outputs = { ... }@inputs: import ./default.nix inputs; + outputs = { ... }@inputs: import ./outputs.nix inputs; } diff --git a/inputs.nix b/inputs.nix new file mode 100644 index 00000000..33191637 --- /dev/null +++ b/inputs.nix @@ -0,0 +1,10 @@ +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + flakeCompat = fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + }; + kittywitch = import flakeCompat { + src = ./.; + }; +in kittywitch.defaultNix.inputs diff --git a/outputs.nix b/outputs.nix new file mode 100644 index 00000000..5740f6a3 --- /dev/null +++ b/outputs.nix @@ -0,0 +1,122 @@ +{ self, utils, nixpkgs, darwin, home-manager, ragenix, scalpel, mach-nix, arcexprs, ... }@inputs: let + tree = (inputs.tree.tree { + inherit inputs; + folder = ./.; + config = { + "/" = { + excludes = [ + "flake" + "default" + ]; + }; + "nixos/modules" = { + functor = { + enable = true; + external = with (import (arcexprs + "/modules")).nixos; [ + base16 + base16-shared + ]; + }; + }; + "home/modules" = { + functor = { + enable = true; + external = with (import (arcexprs + "/modules")).home-manager; [ + base16 + base16-shared + ]; + }; + }; + "home".evaluateDefault = true; + "home/*" = { + functor.enable = true; + }; + }; + }).impure; + lib = inputs.nixpkgs.lib; + inherit (lib.attrsets) mapAttrs; + inherit (lib.lists) singleton; +in utils.lib.mkFlake { + inherit self inputs; + supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; + channelsConfig.allowUnfree = true; + + hostDefaults = { + system = "x86_64-linux"; + extraArgs = { + inherit inputs tree; + }; + }; + + hosts = let + outputForSystem = system: { + "x86_64-linux" = "nixosConfigurations"; + "aarch64-darwin" = "darwinConfigurations"; + }.${system}; + builderForSystem = system: { + "x86_64-linux" = nixpkgs.lib.nixosSystem; + "aarch64-darwin" = darwin.lib.darwinSystem; + }.${system}; + modulesForSystem = system: { + "x86_64-linux" = [ + home-manager.nixosModules.home-manager + ragenix.nixosModules.age + tree.nixos.modules + ]; + "aarch64-darwin" = [ + home-manager.darwinModules.home-manager + ragenix.nixosModules.age + tree.darwin.modules + ]; + }.${system}; + mapSystem = system: name: path: { + inherit system; + output = outputForSystem system; + builder = builderForSystem system; + modules = (modulesForSystem system) ++ [ + path + ]; + extraArgs = { + machine = name; + }; + }; + in mapAttrs (mapSystem "x86_64-linux") tree.nixos.systems + // mapAttrs (mapSystem "aarch64-darwin") tree.darwin.systems; + + outputsBuilder = channels: { + nixosConfigurations = mapAttrs(_: sys: sys.extendModules { + modules = [ scalpel.nixosModule ]; + specialArgs = { + prev = sys; + }; + }) self.nixosConfigurations; + + homeManagerConfigurations = mapAttrs (name: path: home-manager.lib.homeManagerConfiguration { + pkgs = channels.nixpkgs; + extraSpecialArgs = { + inherit inputs tree; + machine = name; + }; + modules = [ + ({ config, ... }: { + home = { + username = "kat"; + stateVersion = "22.11"; + homeDirectory = "/home/kat"; + }; + }) + path + ]; + }) tree.home; + + inherit tree; + }; + + devShells = { + "python" = mach-nix.mkPythonShell { + python = "python310"; + requirements = '' + ''; + }; + }; +}