diff --git a/flake.lock b/flake.lock index 233411d..29cdbca 100644 --- a/flake.lock +++ b/flake.lock @@ -429,24 +429,6 @@ "type": "github" } }, - "flake-utils_4": { - "inputs": { - "systems": "systems_5" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "fromYaml": { "flake": false, "locked": { @@ -984,8 +966,7 @@ "stylix": "stylix", "systems": "systems_4", "treefmt-nix": "treefmt-nix_2", - "unstable": "unstable", - "utils": "utils" + "unstable": "unstable" } }, "stylix": { @@ -1082,21 +1063,6 @@ "type": "github" } }, - "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -1152,24 +1118,6 @@ "repo": "nixpkgs", "type": "github" } - }, - "utils": { - "inputs": { - "flake-utils": "flake-utils_4" - }, - "locked": { - "lastModified": 1722363685, - "narHash": "sha256-XCf2PIAT6lH7BwytgioPmVf/wkzXjSKScC4KzcZgb64=", - "owner": "gytis-ivaskevicius", - "repo": "flake-utils-plus", - "rev": "6b10f51ff73a66bb29f3bc8151a59d217713f496", - "type": "github" - }, - "original": { - "owner": "gytis-ivaskevicius", - "repo": "flake-utils-plus", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index b9b7ff6..431a96f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,91 @@ { description = "C's Nix-Config"; + outputs = { + self, + nixpkgs, + flake-parts, + ... + } @ inputs: let + mods = import ./modules; + mkLinuxSystem = mod: + nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = + [ + inputs.home-manager.nixosModules.home-manager + inputs.stylix.nixosModules.stylix + inputs.agenix.nixosModules.default + { + nixpkgs.config.allowUnfree = true; + nixpkgs.overlays = [self.overlays.default]; + } + mod + ] + ++ mods.sharedModules; + }; + in + flake-parts.lib.mkFlake {inherit self inputs;} { + imports = [ + inputs.flake-parts.flakeModules.easyOverlay + inputs.pre-commit-hooks.flakeModule + inputs.treefmt-nix.flakeModule + ]; + + systems = import inputs.systems; + + flake = { + inherit (mods) homeManagerModules nixosModules; + # TODO: use ./hosts/ + nixosConfigurations = { + artemis = mkLinuxSystem ./hosts/artemis; + hermes = mkLinuxSystem ./hosts/hermes; + }; + }; + + perSystem = { + config, + pkgs, + final, + system, + inputs', + #self', + ... + }: { + _module.args.pkgs = inputs'.nixpkgs.legacyPackages.extend self.overlays.default; + overlayAttrs = config.packages // {unstable = inputs.unstable.legacyPackages.${system};}; + + pre-commit.check.enable = false; + pre-commit.settings.hooks.alejandra.enable = true; + + treefmt.config = { + projectRootFile = "flake.nix"; + programs.alejandra.enable = true; + }; + + devShells.default = final.mkShell { + meta.description = "Default dev shell"; + inputsFrom = [config.pre-commit.devShell config.treefmt.build.devShell]; + packages = with final; [just git nixvim cachix jq devour-flake agenix deadnix]; + }; + + apps = nixpkgs.lib.mapAttrs' (name: value: nixpkgs.lib.nameValuePair ("deploy-" + name) value) (inputs.nixinate.nixinate.${system} self).nixinate; + + packages = { + nixvim = inputs.nixvim.packages.${system}.default; + agenix = inputs.agenix.packages.${system}.default; + vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;}; + devour-flake = pkgs.callPackage inputs.devour-flake {}; + jellyfin-ffmpeg = pkgs.jellyfin-ffmpeg.override { + ffmpeg_6-full = pkgs.ffmpeg_6-full.override { + withMfx = false; + withVpl = true; + }; + }; + }; + }; + }; + inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -28,8 +113,6 @@ inputs.darwin.follows = ""; }; - utils.url = "github:gytis-ivaskevicius/flake-utils-plus"; - home-manager = { url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; @@ -59,100 +142,14 @@ flake-compat.follows = "flake-compat"; }; }; + flake-compat.url = "github:edolstra/flake-compat"; flake-parts.url = "github:hercules-ci/flake-parts"; + systems.url = "github:nix-systems/default"; #systems.url = "github:nix-systems/default-linux"; #systems.url = "github:nix-systems/x86_64-linux"; + treefmt-nix.url = "github:numtide/treefmt-nix"; }; - - outputs = { - self, - disko, - nixpkgs, - flake-parts, - nixinate, - utils, - home-manager, - ... - } @ inputs: let - mods = import ./modules {inherit utils;}; - mkLinuxSystem = mod: - nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; - modules = - [ - inputs.home-manager.nixosModules.home-manager - inputs.stylix.nixosModules.stylix - inputs.agenix.nixosModules.default - { - nixpkgs.config.allowUnfree = true; - nixpkgs.overlays = [self.overlays.default]; - } - mod - ] - ++ mods.sharedModules; - }; - in - flake-parts.lib.mkFlake {inherit self inputs;} { - imports = [ - inputs.flake-parts.flakeModules.easyOverlay - inputs.pre-commit-hooks.flakeModule - inputs.treefmt-nix.flakeModule - ]; - - systems = import inputs.systems; - - flake = { - inherit (mods) homeManagerModules nixosModules; - nixosConfigurations = { - artemis = mkLinuxSystem ./hosts/artemis; - hermes = mkLinuxSystem ./hosts/hermes; - }; - #nixosConfigurations.artemis = inputs.nixpkgs.lib.nixosSystem {}; - }; - - perSystem = { - config, - pkgs, - final, - system, - inputs', - self', - ... - }: { - _module.args.pkgs = inputs'.nixpkgs.legacyPackages.extend self.overlays.default; - overlayAttrs = config.packages // {unstable = inputs.unstable.legacyPackages.${system};}; - - pre-commit.check.enable = false; - pre-commit.settings.hooks.alejandra.enable = true; - - treefmt.config = { - projectRootFile = "flake.nix"; - programs.alejandra.enable = true; - }; - - devShells.default = final.mkShell { - meta.description = "Default dev shell"; - inputsFrom = [config.pre-commit.devShell config.treefmt.build.devShell]; - packages = with final; [just git nixvim cachix jq devour-flake agenix deadnix]; - }; - - apps = nixpkgs.lib.mapAttrs' (name: value: nixpkgs.lib.nameValuePair ("deploy-" + name) value) (nixinate.nixinate.${system} self).nixinate; - - packages = { - nixvim = inputs.nixvim.packages.${system}.default; - agenix = inputs.agenix.packages.${system}.default; - vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;}; - devour-flake = pkgs.callPackage inputs.devour-flake {}; - jellyfin-ffmpeg = pkgs.jellyfin-ffmpeg.override { - ffmpeg_6-full = pkgs.ffmpeg_6-full.override { - withMfx = false; - withVpl = true; - }; - }; - }; - }; - }; } diff --git a/hosts/default.nix b/hosts/default.nix index 2f8e4e7..9fcbfe4 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,6 +1,5 @@ { inputs, - utils, mods, self, ... diff --git a/modules/default.nix b/modules/default.nix index 85c4c88..f31f2d2 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,5 +1,21 @@ -{utils, ...}: let - nixosModules = utils.lib.exportModules [ +let + exportModules = args: + builtins.listToAttrs (map (arg: { + name = let + str = baseNameOf arg; + suffix = ".nix"; + sufLen = builtins.stringLength suffix; + sLen = builtins.stringLength str; + in + if sufLen <= sLen && suffix == builtins.substring (sLen - sufLen) sufLen str + then builtins.substring 0 (sLen - sufLen) str + else str; + + value = import arg; + }) + args); + + nixosModules = exportModules [ ./nix.nix ./pinentry-fix.nix ./hm.nix @@ -9,7 +25,7 @@ ./tailscale.nix ./secret.nix ]; - homeManagerModules = utils.lib.exportModules [ + homeManagerModules = exportModules [ ./trayscale.nix ]; sharedModules = with nixosModules; [