From 61d433c8e7cc17d5b921329fca9baf7c3d528ade Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Tue, 27 Dec 2022 01:19:08 -0600 Subject: flake: rework flake inputs, overlays and platforms --- flake.nix | 72 +++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 25 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 1984f07..c1538c4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; - nixpkgsUnstable.url = "github:nixos/nixpkgs"; + unstable.url = "github:nixos/nixpkgs"; home-manager = { url = "github:nix-community/home-manager/release-22.11"; @@ -14,47 +14,69 @@ }; outputs = - { self, nixpkgs, nixpkgsUnstable, home-manager - , nur, impermanence, hm-isolation, ... }: - with nixpkgs.lib; let + { self, nixpkgs, unstable, home-manager, nur, impermanence, hm-isolation, ... }: let + system = "x86_64-linux"; + + pkgs = pkgsNoLocal.extend self.overlays.default; + pkgsNoLocal = importPkgs nixpkgs; + + importPkgs = flake: import flake { + inherit system; + + config.android_sdk.accept_license = true; + overlays = [ nur.overlay ]; + }; + util = import ./util; - inherit (util nixpkgs.lib) importAll; + inherit (util pkgs.lib) importAll; - pkgSet = pkgs: import ./pkgs pkgs; - in { - packages."x86_64-linux" = pkgSet nixpkgs.legacyPackages."x86_64-linux"; + local = import ./pkgs; + in with pkgs.lib; { + packages.${system} = local pkgs pkgsNoLocal; - overlay = self: super: { - local = pkgSet super; - unstable = import nixpkgsUnstable { inherit (super) config system; }; + overlays.default = final: prev: { + local = local final prev; + unstable = (importPkgs unstable).extend self.overlays.default; }; nixosConfigurations = let - hostConfig = host: (makeOverridable nixosSystem) { - system = "x86_64-linux"; - modules = [ (import ./sys { inherit self impermanence; }) host ]; + hostConfig = host: (makeOverridable nixpkgs.lib.nixosSystem) { + inherit pkgs system; + + modules = [ + ./sys + host + nixpkgs.nixosModules.notDetected + impermanence.nixosModule + ]; }; in mapAttrs (_: hostConfig) (importAll { root = ./sys/platform; }); homeConfigurations = let - configuration = import ./home { - inherit self nixpkgs nixpkgsUnstable nur hm-isolation; + registry = { ... }: { + config.nix.registry = { + "nixpkgs".flake = nixpkgs; + "unstable".flake = unstable; + "nur".flake = nur; + }; }; - username = "ale"; - home = platform: home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { system = "x86_64-linux"; }; - modules = [ configuration platform ]; + inherit pkgs; - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - extraSpecialArgs = {}; + modules = [ + ./home + platform + registry + hm-isolation.homeManagerModule + ]; }; - platformHome = name: platform: { - name = "${username}@${name}"; + platformHome = name: platform: let value = home platform; + in { + inherit value; + name = "${value.config.home.username}@${name}"; }; in mapAttrs' platformHome (importAll { root = ./home/platform; }); }; -- cgit v1.2.3