From 05920009619551d2c391133ea0cdefca1eb43b43 Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Tue, 4 Oct 2022 16:45:59 +0200 Subject: [PATCH] Simplified flake --- flake.nix | 149 +++++++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 81 deletions(-) diff --git a/flake.nix b/flake.nix index 1c87a01..2218dd0 100644 --- a/flake.nix +++ b/flake.nix @@ -3,12 +3,12 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/release-22.05"; + nixpkgs-u.url = "github:NixOS/nixpkgs/nixos-unstable"; + home-manager = { url = "github:nix-community/home-manager/release-22.05"; inputs.nixpkgs.follows = "nixpkgs"; }; - - nixpkgs-u.url = "github:NixOS/nixpkgs/nixos-unstable"; # home-manager-u = { # url = "github:nix-community/home-manager"; # inputs.nixpkgs.follows = "nixpkgs-u"; @@ -19,24 +19,15 @@ nix-rice = { url = "github:bertof/nix-rice"; - inputs = { - nixpkgs.follows = "nixpkgs-u"; - flake-utils.follows = "flake-utils"; - }; + inputs = { nixpkgs.follows = "nixpkgs-u"; flake-utils.follows = "flake-utils"; }; }; pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; - inputs = { - nixpkgs.follows = "nixpkgs-u"; - flake-utils.follows = "flake-utils"; - }; + inputs = { nixpkgs.follows = "nixpkgs-u"; flake-utils.follows = "flake-utils"; }; }; tex2nix = { url = "github:Mic92/tex2nix"; - inputs = { - nixpkgs.follows = "nixpkgs-u"; - flake-utils.follows = "flake-utils"; - }; + inputs = { nixpkgs.follows = "nixpkgs-u"; flake-utils.follows = "flake-utils"; }; }; }; @@ -53,15 +44,24 @@ , pre-commit-hooks }: let - overlaysBuilder = system: [ - (_: _: { - inherit (tex2nix.packages.${system}) tex2nix; - stable = pkgs { inherit system; }; - unstable = pkgs-u { inherit system; }; - }) + + config = { + allowUnfree = true; + extraOptions = "experimental-features = nix-command flakes"; + permittedInsecurePackages = [ "electron-9.4.4" ]; # authy dependency + }; + + overlaysBuilder = { system }: [ + # Packages + (_: _: { stable = pkgs { inherit system; }; unstable = pkgs-u { inherit system; }; }) + + # Nix rice (nix-rice.overlays.default) (import ./rice.nix) + + # Flakes packages (final: _: { + inherit (tex2nix.packages.${system}) tex2nix; update-background = final.callPackage ./custom/update-background { backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+"; }; @@ -69,53 +69,40 @@ palette = final.rice.colorPalette; font = final.rice.font.normal; }; - sddm-theme-clairvoyance = - final.callPackage ./custom/sddm-theme-clairvoyance { - wallpaper = ./wallpapers/comfy_waves.jpg; - }; + sddm-theme-clairvoyance = final.callPackage ./custom/sddm-theme-clairvoyance { + wallpaper = ./wallpapers/comfy_waves.jpg; + }; }) ]; - defaultConfig = { - extraOptions = "experimental-features = nix-command flakes"; - allowUnfree = true; - permittedInsecurePackages = [ "electron-9.4.4" ]; # authy dependency - }; - nixpkgsSettings = - { system, overlays ? overlaysBuilder system, config ? defaultConfig }: { - inherit system overlays config; - }; - pkgs = s: import nixpkgs (nixpkgsSettings s); - pkgs-u = s: import nixpkgs-u (nixpkgsSettings s); - nixModule = system: { pkgs, ... }: { - nixpkgs = nixpkgsSettings { inherit system; }; - nix = { - package = pkgs.unstable.nixVersions.stable; - extraOptions = "experimental-features = nix-command flakes"; - }; - }; - homeManagerSettings = { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - }; - }; - commonBaseModules = [ - ./nixos_modules/bertof_user.nix - ./nixos_modules/automatic-garbage-collection.nix - ./nixos_modules/zerotier.nix - ]; + modulesBuilder = { system }: + let overlays = overlaysBuilder { inherit system; }; in + [ + # Nix configuration + ({ pkgs, ... }: { + nixpkgs = { inherit system overlays config; }; + nix = { + package = pkgs.nixVersions.stable; + extraOptions = "experimental-features = nix-command flakes"; + }; + }) - homeManagerModules = users: [ - home-manager.nixosModules.home-manager - homeManagerSettings - { home-manager.users = users; } - ]; - # homeManagerUModules = users: [ - # home-manager-u.nixosModules.home-manager - # homeManagerSettings - # { home-manager.users = users; } - # ]; + # Home manager configuration + home-manager.nixosModules.home-manager + ({ home-manager = { useGlobalPkgs = true; useUserPackages = true; }; }) + + # Common modules + ./nixos_modules/bertof_user.nix + ./nixos_modules/automatic-garbage-collection.nix + ./nixos_modules/zerotier.nix + ]; + + pkgs = { system }: + let overlays = overlaysBuilder { inherit system; }; in + import nixpkgs { inherit system config overlays; }; + pkgs-u = { system }: + let overlays = overlaysBuilder { inherit system; }; in + import nixpkgs-u { inherit system config overlays; }; odinBaseModules = [ ./odin/hardware-configuration.nix @@ -133,17 +120,17 @@ odinIntelBuilder = { extraModules ? [ ] }: nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - modules = [ (nixModule system) ] - ++ commonBaseModules ++ odinBaseModules ++ odinIntelModules - ++ (homeManagerModules { bertof = import ./odin/hm.nix; }) + modules = (modulesBuilder { inherit system; }) + ++ odinBaseModules ++ odinIntelModules + ++ [{ home-manager.users.bertof = import ./odin/hm.nix; }] ++ extraModules; }; odinNvidiaBuilder = { extraModules ? [ ] }: nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - modules = [ (nixModule system) ] - ++ commonBaseModules ++ odinBaseModules ++ odinNvidiaModules - ++ (homeManagerModules { bertof = import ./odin/hm.nix; }) + modules = (modulesBuilder { inherit system; }) + ++ odinBaseModules ++ odinNvidiaModules + ++ [{ home-manager.users.bertof = import ./odin/hm.nix; }] ++ extraModules; }; @@ -160,9 +147,9 @@ thorBuilder = { extraModules ? [ ] }: nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - modules = [ (nixModule system) ] - ++ commonBaseModules ++ thorBaseModules - ++ (homeManagerModules { bertof = import ./thor/hm.nix; }) + modules = (modulesBuilder { inherit system; }) + ++ thorBaseModules + ++ [{ home-manager.users.bertof = import ./thor/hm.nix; }] ++ extraModules; }; @@ -175,9 +162,9 @@ lokiBuilder = { extraModules ? [ ] }: nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - modules = [ (nixModule system) ] - ++ commonBaseModules ++ lokiBaseModules - ++ (homeManagerModules { bertof = import ./loki/hm.nix; }) + modules = (modulesBuilder { inherit system; }) + ++ lokiBaseModules + ++ [{ home-manager.users.bertof = import ./loki/hm.nix; }] ++ extraModules; }; @@ -189,9 +176,9 @@ freyaBuilder = { extraModules ? [ ] }: nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - modules = [{ nixpkgs = nixpkgsSettings { inherit system; }; }] - ++ commonBaseModules ++ freyaBaseModules - ++ (homeManagerModules { bertof = import ./freya/hm.nix; }) + modules = (modulesBuilder { inherit system; }) + ++ freyaBaseModules + ++ [{ home-manager.users.bertof = import ./freya/hm.nix; }] ++ extraModules; }; @@ -199,9 +186,9 @@ balurBuilder = { extraModules ? [ ] }: nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - modules = [{ nixpkgs = nixpkgsSettings { inherit system; }; }] - ++ commonBaseModules ++ baldurBaseModules - ++ (homeManagerModules { bertof = import ./baldur/hm.nix; }) + modules = (modulesBuilder { inherit system; }) + ++ baldurBaseModules + ++ [{ home-manager.users.bertof = import ./baldur/hm.nix; }] ++ extraModules; }; in