From 35e6b01a56f835b5d7b76757b4876557246b0184 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sun, 21 Jul 2024 21:58:18 +0200 Subject: [PATCH] working flake-parts --- flake.lock | 190 ++++++++++++++++++------- flake.nix | 12 ++ flake/fmt.nix | 33 +++++ {parts => flake}/lib/builders.nix | 0 flake/shell.nix | 28 ++++ hosts/default.nix | 19 +-- hosts/vali/hermit/programs.nix | 4 +- hosts/vali/temperance/programs.nix | 4 +- modules/gui/foot.nix | 4 +- modules/gui/spicetify.nix | 4 +- modules/services/dunst.nix | 4 +- modules/services/greetd.nix | 8 +- modules/services/ssh.nix | 12 +- modules/styling/quickshell/default.nix | 4 +- modules/wms/wayland/services.nix | 5 +- 15 files changed, 243 insertions(+), 88 deletions(-) create mode 100644 flake/fmt.nix rename {parts => flake}/lib/builders.nix (100%) create mode 100644 flake/shell.nix diff --git a/flake.lock b/flake.lock index a12ceb7..2c2172f 100644 --- a/flake.lock +++ b/flake.lock @@ -222,7 +222,28 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils_6", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717408969, + "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", + "owner": "numtide", + "repo": "devshell", + "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "devshell_2": { + "inputs": { + "flake-utils": "flake-utils_7", "nixpkgs": [ "nixvim", "nixpkgs" @@ -276,7 +297,7 @@ }, "emacs-overlay": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs_3", "nixpkgs-stable": "nixpkgs-stable" }, @@ -610,11 +631,11 @@ "systems": "systems_4" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -625,7 +646,7 @@ }, "flake-utils_2": { "inputs": { - "systems": "systems_6" + "systems": "systems_5" }, "locked": { "lastModified": 1710146030, @@ -660,23 +681,8 @@ } }, "flake-utils_4": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_5": { "inputs": { - "systems": "systems_9" + "systems": "systems_8" }, "locked": { "lastModified": 1710146030, @@ -692,10 +698,43 @@ "type": "github" } }, + "flake-utils_5": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flake-utils_6": { "inputs": { "systems": "systems_10" }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_7": { + "inputs": { + "systems": "systems_11" + }, "locked": { "lastModified": 1701680307, "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", @@ -710,9 +749,9 @@ "type": "github" } }, - "flake-utils_7": { + "flake-utils_8": { "inputs": { - "systems": "systems_12" + "systems": "systems_13" }, "locked": { "lastModified": 1685518550, @@ -1064,7 +1103,7 @@ "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs_4", - "systems": "systems_5", + "systems": "systems_6", "xdph": "xdph" }, "locked": { @@ -1221,7 +1260,7 @@ }, "lib-aggregate": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_6", "nixpkgs-lib": "nixpkgs-lib_3" }, "locked": { @@ -1254,7 +1293,7 @@ }, "lix-module": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "flakey-profile": "flakey-profile", "lix": "lix", "nixpkgs": [ @@ -1313,7 +1352,7 @@ "neovim-flake": { "inputs": { "flake-parts": "flake-parts_3", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_4", "mnw": "mnw", "nil": "nil", "nixpkgs": [ @@ -1420,7 +1459,7 @@ "plugin-vim-vsnip": "plugin-vim-vsnip", "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", - "systems": "systems_8", + "systems": "systems_9", "zig": "zig" }, "locked": { @@ -1777,6 +1816,22 @@ "type": "github" } }, + "nixpkgs_13": { + "locked": { + "lastModified": 1719690277, + "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1718714799, @@ -1907,7 +1962,7 @@ }, "nixvim": { "inputs": { - "devshell": "devshell", + "devshell": "devshell_2", "flake-compat": "flake-compat_5", "flake-parts": "flake-parts_8", "git-hooks": "git-hooks_2", @@ -3578,6 +3633,7 @@ "agenix": "agenix", "ags": "ags", "anyrun": "anyrun", + "devshell": "devshell", "doom-emacs-config": "doom-emacs-config", "doomemacs": "doomemacs", "emacs-overlay": "emacs-overlay", @@ -3597,7 +3653,8 @@ "schizofox": "schizofox", "spicetify-nix": "spicetify-nix", "split-monitor-workspaces": "split-monitor-workspaces", - "stylix": "stylix" + "stylix": "stylix", + "treefmt-nix": "treefmt-nix_3" } }, "rust-overlay": { @@ -3639,7 +3696,7 @@ "nixpkgs" ], "searx-randomizer": "searx-randomizer", - "systems": "systems_11" + "systems": "systems_12" }, "locked": { "lastModified": 1719058240, @@ -3680,7 +3737,7 @@ }, "spicetify-nix": { "inputs": { - "flake-utils": "flake-utils_7", + "flake-utils": "flake-utils_8", "nixpkgs": "nixpkgs_11" }, "locked": { @@ -3777,6 +3834,21 @@ } }, "systems_11": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_12": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", @@ -3791,7 +3863,7 @@ "type": "github" } }, - "systems_12": { + "systems_13": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -3852,21 +3924,6 @@ } }, "systems_5": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_6": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -3881,6 +3938,21 @@ "type": "github" } }, + "systems_6": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, "systems_7": { "locked": { "lastModified": 1681028828, @@ -3969,6 +4041,24 @@ "type": "github" } }, + "treefmt-nix_3": { + "inputs": { + "nixpkgs": "nixpkgs_13" + }, + "locked": { + "lastModified": 1721458737, + "narHash": "sha256-wNXLQ/ATs1S4Opg1PmuNoJ+Wamqj93rgZYV3Di7kxkg=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "888bfb10a9b091d9ed2f5f8064de8d488f7b7c97", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1656928814, @@ -4017,7 +4107,7 @@ "zig": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_5", "nixpkgs": "nixpkgs_6" }, "locked": { diff --git a/flake.nix b/flake.nix index 474f431..d48bc20 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,11 @@ systems = [ "x86-64_linux" ]; + imports = [ + inputs.treefmt-nix.flakeModule + ./flake/shell.nix + ./flake/fmt.nix + ]; flake = { nixosConfigurations = import ./hosts {inherit inputs withSystem;}; }; @@ -53,6 +58,13 @@ inputs.hyprland.follows = "hyprland"; }; + treefmt-nix.url = "github:numtide/treefmt-nix"; + + devshell = { + url = "github:numtide/devshell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + neovim-flake = { url = "github:notashelf/nvf"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/flake/fmt.nix b/flake/fmt.nix new file mode 100644 index 0000000..ce1c97c --- /dev/null +++ b/flake/fmt.nix @@ -0,0 +1,33 @@ +{ + perSystem = { + config, + pkgs, + ... + }: { + # https://github.com/numtide/treefmt-nix?tab=readme-ov-file#flake-parts + formatter = config.treefmt.build.wrapper; + treefmt = { + projectRootFile = "flake.nix"; + programs = { + alejandra.enable = true; + + shellcheck.enable = true; # cannot be configured, errors on basic bash convention + + prettier = { + enable = true; + package = pkgs.prettierd; + excludes = ["*.age"]; + settings = { + editorconfig = true; + }; + }; + + shfmt = { + enable = true; + # https://flake.parts/options/treefmt-nix.html#opt-perSystem.treefmt.programs.shfmt.indent_size + indent_size = 2; # set to 0 to use tabs + }; + }; + }; + }; +} diff --git a/parts/lib/builders.nix b/flake/lib/builders.nix similarity index 100% rename from parts/lib/builders.nix rename to flake/lib/builders.nix diff --git a/flake/shell.nix b/flake/shell.nix new file mode 100644 index 0000000..b89b72c --- /dev/null +++ b/flake/shell.nix @@ -0,0 +1,28 @@ +{ + perSystem = {pkgs, ...}: { + devShells.default = pkgs.mkShellNoCC { + name = "nichts"; + DIRENV_LOG_FORMAT = ""; + packages = with pkgs; [ + nil # nix language server + alejandra + git # take a guess + statix # no idea + deadnix # clean up unused nix code + + (pkgs.writeShellApplication { + name = "update"; + text = '' + nix flake update && git commit flake.lock -m "flake: bump inputs" + ''; + }) + (pkgs.writeShellApplication { + name = "rebuild"; + text = '' + nh os switch + ''; + }) + ]; + }; + }; +} diff --git a/hosts/default.nix b/hosts/default.nix index 93bfb03..dc7cd53 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -25,7 +25,6 @@ inherit lib; inherit inputs inputs'; inherit self self'; - inherit system; } (args.specialArgs or {}); inherit (args) modules; @@ -39,31 +38,17 @@ in { ./vali/temperance ../modules inputs.home-manager.nixosModules.home-manager - inputs.agenix.nixosModules.default inputs.lix-module.nixosModules.default ]; }; - # temperance = - # lib.nixosSystem rec { - # system = "x86_64-linux"; - # specialArgs = { - # inherit lib; - # inherit - # inputs - # self - # system - # ; - # }; - # }); - hermit = lib.nixosSystem rec { + hermit = mkSystem { + inherit withSystem; system = "x86_64-linux"; - specialArgs = {inherit lib inputs self system;}; modules = [ ./vali/hermit ../modules inputs.home-manager.nixosModules.home-manager - inputs.agenix.nixosModules.default inputs.lix-module.nixosModules.default inputs.nixos-hardware.nixosModules.dell-xps-15-7590-nvidia ]; diff --git a/hosts/vali/hermit/programs.nix b/hosts/vali/hermit/programs.nix index 5b187ef..a988940 100644 --- a/hosts/vali/hermit/programs.nix +++ b/hosts/vali/hermit/programs.nix @@ -1,9 +1,9 @@ { - inputs, + inputs', pkgs, ... }: let - nixpkgs-wayland = inputs.nixpkgs-wayland.packages.${pkgs.system}; + nixpkgs-wayland = inputs'.nixpkgs-wayland.packages; in { environment.systemPackages = with pkgs; [ alejandra diff --git a/hosts/vali/temperance/programs.nix b/hosts/vali/temperance/programs.nix index b9fcfdd..baf2a2a 100644 --- a/hosts/vali/temperance/programs.nix +++ b/hosts/vali/temperance/programs.nix @@ -1,9 +1,9 @@ { - inputs, + inputs', pkgs, ... }: let - nixpkgs-wayland = inputs.nixpkgs-wayland.packages.${pkgs.system}; + nixpkgs-wayland = inputs'.nixpkgs-wayland.packages; in { environment.systemPackages = with pkgs; [ abaddon diff --git a/modules/gui/foot.nix b/modules/gui/foot.nix index baa628a..72b3ba4 100644 --- a/modules/gui/foot.nix +++ b/modules/gui/foot.nix @@ -1,6 +1,6 @@ { config, - inputs, + inputs', lib, pkgs, ... @@ -15,7 +15,7 @@ in { home-manager.users.${username} = { programs.foot = { enable = true; - package = inputs.nixpkgs-wayland.packages.${pkgs.system}.foot; + package = inputs'.nixpkgs-wayland.packages.foot; settings = { main = { term = "foot"; diff --git a/modules/gui/spicetify.nix b/modules/gui/spicetify.nix index a4cbd4d..402ab41 100644 --- a/modules/gui/spicetify.nix +++ b/modules/gui/spicetify.nix @@ -3,12 +3,12 @@ pkgs, lib, inputs, + inputs', ... }: let cfg = config.modules.system.programs.spotify; inherit (config.modules.other.system) username; - spicePkgs = inputs.spicetify-nix.packages.${pkgs.system}.default; - # inherit (inputs.spicetify-nix.packages.${pkgs.system}) spicetify-nix; + spicePkgs = inputs'.spicetify-nix.packages.default; in { config = lib.mkIf cfg.enable { home-manager.users.${username} = { diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index ad6580b..f184435 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -1,6 +1,6 @@ { config, - inputs, + inputs', lib, pkgs, ... @@ -16,7 +16,7 @@ in { home-manager.users.${username} = { services.dunst = { enable = true; - package = inputs.nixpkgs-wayland.packages.${pkgs.system}.dunst; + package = inputs'.nixpkgs-wayland.packages.dunst; settings = { global = { monitor = 1; diff --git a/modules/services/greetd.nix b/modules/services/greetd.nix index 5d46792..bbb376c 100644 --- a/modules/services/greetd.nix +++ b/modules/services/greetd.nix @@ -1,6 +1,6 @@ { config, - inputs, + inputs', lib, pkgs, ... @@ -25,10 +25,10 @@ with lib; let #exec-once=[workspace 1;fullscreen;noanim] ${ pkgs.greetd.${cfg.greeter} }/bin/${cfg.greeter} -l; ${ - inputs.hyprland.packages.${pkgs.system}.hyprland + inputs'.hyprland.packages.hyprland }/bin/hyprctl dispatch exit #exec-once=${ - inputs.hyprland.packages.${pkgs.system}.hyprland + inputs'.hyprland.packages.hyprland }/bin/hyprctl dispatch focuswindow ${cfg.greeter} ''; in { @@ -49,7 +49,7 @@ in { enable = true; settings.default_session = { command = "${ - inputs.hyprland.packages.${pkgs.system}.hyprland + inputs'.hyprland.packages.hyprland }/bin/Hyprland --config ${hyprlandConfig}"; user = username; }; diff --git a/modules/services/ssh.nix b/modules/services/ssh.nix index 28b6022..b34b3dd 100644 --- a/modules/services/ssh.nix +++ b/modules/services/ssh.nix @@ -9,6 +9,14 @@ with lib; let inherit (config.modules.other.system) username; in { options.modules.programs.ssh.enable = mkEnableOption "ssh"; - - config = mkIf cfg.enable {programs.ssh = {startAgent = true;};}; + config = { + programs.ssh.startAgent = true; + services.openssh = { + enable = true; + settings = { + PasswordAuthentication = false; + PermitRootLogin = "no"; + }; + }; + }; } diff --git a/modules/styling/quickshell/default.nix b/modules/styling/quickshell/default.nix index f9c4fcc..15a7b03 100644 --- a/modules/styling/quickshell/default.nix +++ b/modules/styling/quickshell/default.nix @@ -1,7 +1,7 @@ { config, lib, - system, + #system, inputs, pkgs, ... @@ -17,7 +17,7 @@ in { environment.systemPackages = with pkgs; [ qt6.qtimageformats qt6.qt5compat - quickshell.packages.${system}.default + #quickshell.packages.${system}.default pamtester ]; home-manager.users.${username}.xdg.configFile."quickshell/manifest.conf".text = toKeyValue {} { diff --git a/modules/wms/wayland/services.nix b/modules/wms/wayland/services.nix index 92f2c18..8950587 100644 --- a/modules/wms/wayland/services.nix +++ b/modules/wms/wayland/services.nix @@ -1,12 +1,11 @@ { - pkgs, - inputs, + inputs', config, ... }: { programs.niri = { enable = true; - package = inputs.niri.packages.${pkgs.system}.niri-unstable; + package = inputs'.niri.packages.niri-unstable; }; services = { greetd = {