From 73ee4b2873f7d27ff93fce2db147e86d54b2a07d Mon Sep 17 00:00:00 2001 From: RGBCube Date: Thu, 23 Nov 2023 13:46:44 +0300 Subject: [PATCH] Clean up flake --- flake.lock | 70 +++++++++++++++------ flake.nix | 179 +++++++++++++++++++++++------------------------------ 2 files changed, 130 insertions(+), 119 deletions(-) diff --git a/flake.lock b/flake.lock index ec99d0d..7a7eb8e 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1700374854, - "narHash": "sha256-mJOk9Rg5dbh9LorTKaiXlxCpfLZju/ngSvDABPzv870=", + "lastModified": 1700720546, + "narHash": "sha256-p31fe4lp2KBCyUf58mgai1xYjMLl5S0PQiSvv9+1j/Y=", "owner": "nix-community", "repo": "fenix", - "rev": "95b4121cdcf9d6e91666305a1a9c57e483947e15", + "rev": "5ade7808d45671b545f3516adf61bc9a604a6246", "type": "github" }, "original": { @@ -21,18 +21,18 @@ "type": "github" } }, - "home-manager": { + "homeManager": { "inputs": { "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1700386809, - "narHash": "sha256-2IPxWo0Yplv+70EueZVLTwRAijax0tirYp5Jh0QV1A4=", + "lastModified": 1700695018, + "narHash": "sha256-MAiPLgBF4GLzSOlhnPCDWkWW5CDx4i7ApIYaR+TwTVg=", "owner": "nix-community", "repo": "home-manager", - "rev": "9a4725afa67db35cdf7be89f30527d745194cafa", + "rev": "134deb46abd5d0889d913b8509413f6f38b0811e", "type": "github" }, "original": { @@ -50,11 +50,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1700397206, - "narHash": "sha256-ityVJcy3I/E8soXctwWveg58+cXOSQXhDIcU6YR2gjI=", + "lastModified": 1700696626, + "narHash": "sha256-Rr6s2HE9v0AlI630WAE+12usUJpwd3fAP6Gvk7rF5v4=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "646f4bc63861e03b01fed3833bb65d1d014e1bf3", + "rev": "e55c5a916ab942e641339471bc80b6d2efbc2044", "type": "github" }, "original": { @@ -106,11 +106,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1700204040, - "narHash": "sha256-xSVcS5HBYnD3LTer7Y2K8ZQCDCXMa3QUD1MzRjHzuhI=", + "lastModified": 1700390070, + "narHash": "sha256-de9KYi8rSJpqvBfNwscWdalIJXPo8NjdIZcEJum1mH0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad", + "rev": "e4ad989506ec7d71f7302cc3067abd82730a4beb", "type": "github" }, "original": { @@ -123,19 +123,20 @@ "root": { "inputs": { "fenix": "fenix", - "home-manager": "home-manager", + "homeManager": "homeManager", "hyprland": "hyprland", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "utils": "utils" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1700247620, - "narHash": "sha256-+Xg0qZLbC9dZx0Z6JbaVHR/BklAr2I83dzKLB8r41c8=", + "lastModified": 1700642897, + "narHash": "sha256-LoyZRcl0bBuSnV9SVqrf+vUxN1u9FeYk4vgQS/kyCOI=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "255eed40c45fcf108ba844b4ad126bdc4e7a18df", + "rev": "7ceefc7ee981f7dd9de4cfdd070696e48b4ab43e", "type": "github" }, "original": { @@ -160,6 +161,39 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "wlroots": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 2d04dee..703b8f6 100644 --- a/flake.nix +++ b/flake.nix @@ -2,11 +2,6 @@ description = "My NixOS configurations."; nixConfig = { - extra-experimental-features = '' - nix-command - flakes - ''; - extra-substituters = '' https://nix-community.cachix.org/ https://hyprland.cachix.org/ @@ -28,6 +23,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + utils = { + url = "github:numtide/flake-utils"; + }; + fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -38,112 +37,90 @@ }; }; - outputs = { nixpkgs, homeManager, fenix, ... } @ inputs: let - machines = [ - ./machines/enka - ]; + outputs = { nixpkgs, homeManager, utils, fenix, hyprland, ... }: utils.lib.eachDefaultSystem (system: let + lib = nixpkgs.lib; - architectures = [ - "x86_64-linux" - ]; + ulib = rec { + recursiveUpdate3 = x: y: z: lib.recursiveUpdate x (lib.recursiveUpdate y z); - lib = nixpkgs.lib // { - recursiveUpdate3 = x: y: z: lib.recursiveUpdate x (lib.recursiveUpdate y z); - }; - - theme = import ./themes/gruvbox.nix; - - # GENERAL - imports = importPaths: { - imports = importPaths; - }; - - enabled = attributes: attributes // { - enable = true; - }; - - normalUser = attributes: attributes // { - isNormalUser = true; - }; - - # SYSTEM - systemConfiguration = attributes: attributes; - - systemPackages = packages: systemConfiguration { - environment.systemPackages = packages; - }; - - systemFonts = fonts: systemConfiguration { - fonts.packages = fonts; - }; - - # HOME - homeConfiguration = userName: attributes: systemConfiguration { - home-manager.users = builtins.foldl' lib.recursiveUpdate {} (builtins.map (userName: { - ${userName} = attributes; - }) (if builtins.isList userName then userName else [ userName ])); - }; - - homePackages = userName: packages: homeConfiguration userName { - home.packages = packages; - }; - - importConfiguration = configurationDirectory: hostPlatform: let - hostName = builtins.baseNameOf configurationDirectory; - - pkgs = import nixpkgs { - system = hostPlatform; - config.allowUnfree = true; - - overlays = [ - fenix.overlays.default - ]; + imports = paths: { + imports = paths; }; - hyprland = inputs.hyprland.packages.${hostPlatform}.hyprland; - - arguments = { - inherit lib pkgs hyprland theme systemConfiguration systemPackages homeConfiguration systemFonts homePackages imports enabled normalUser; + enabled = attributes: attributes // { + enable = true; }; - defaultConfiguration = { - nix.gc = { - automatic = true; - dates = "daily"; - options = "--delete-older-than 3d"; - persistent = true; - }; - - nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; - nix.registry.nixpkgs.flake = nixpkgs; - - nix.optimise.automatic = true; - - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - environment.defaultPackages = []; - - boot.tmp.cleanOnBoot = true; - - networking.hostName = hostName; - - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; + normalUser = attributes: attributes // { + isNormalUser = true; }; + systemConfiguration = attributes: attributes; + + systemPackages = packages: systemConfiguration { + environment.systemPackages = packages; + }; + + systemFonts = fonts: systemConfiguration { + fonts.packages = fonts; + }; + + homeConfiguration = user: attributes: systemConfiguration { + home-manager.users = builtins.foldl' lib.recursiveUpdate {} (builtins.map (user: { + ${user} = attributes; + }) (if builtins.isList user then user else [ user ])); + }; + + homePackages = user: packages: homeConfiguration user { + home.packages = packages; + }; + }; + + defaultConfiguration = host: ulib.systemConfiguration { + nix.gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than 3d"; + persistent = true; + }; + + nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; + nix.registry.nixpkgs.flake = nixpkgs; + + nix.optimise.automatic = true; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + + nixpkgs.config.allowUnfree = true; + nixpkgs.overlays = [ + fenix.overlays.default + hyprland.overlays.default + ]; + + environment.defaultPackages = []; + + boot.tmp.cleanOnBoot = true; + + networking.hostName = host; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + }; + + specialArgs = { + inherit ulib; + }; + in { + nixosConfigurations.enka = lib.nixosSystem { + inherit specialArgs; + modules = [ homeManager.nixosModules.default - defaultConfiguration - configurationDirectory + (defaultConfiguration "enka") + ./machines/enka ]; - in { - nixosConfigurations.${hostName} = lib.nixosSystem { - specialArgs = arguments; - modules = modules; - }; }; - in builtins.foldl' lib.recursiveUpdate {} (builtins.concatMap (architecture: builtins.map (configuration: importConfiguration configuration architecture) machines) architectures); + }); }