diff --git a/checks/alejandra.nix b/checks/alejandra.nix index 6191e3db..f2f45117 100644 --- a/checks/alejandra.nix +++ b/checks/alejandra.nix @@ -3,8 +3,11 @@ mkTest, lib, alejandra, + generatedFiles, }: let + inherit (lib) concatStringsSep; inherit (lib.sources) sourceFilesBySuffices; + excludes = concatStringsSep " " (map (f: "--exclude ./${f}") generatedFiles); in mkTest { name = "lint-alejandra"; @@ -12,12 +15,7 @@ in checkInputs = [alejandra]; checkPhase = '' mkdir -p $out - alejandra --check \ - --exclude ./home-config/dotfiles/emacs.d/share/templates/ \ - --exclude ./pkgs/_sources/ \ - --exclude ./nixos-config/yui/hardware-configuration.nix \ - --exclude ./nixos-config/ren/hardware-configuration.nix \ - . \ - | tee $out/test.log + echo alejandra --check ${excludes} . | tee $out/test.log + alejandra --check ${excludes} . | tee $out/test.log ''; } diff --git a/checks/deadnix.nix b/checks/deadnix.nix new file mode 100644 index 00000000..8f279d8e --- /dev/null +++ b/checks/deadnix.nix @@ -0,0 +1,24 @@ +{ + pkgs, + self, + mkTest, + lib, + flake-inputs, + generatedFiles, +}: let + inherit (lib) concatStringsSep; + inherit (lib.sources) sourceFilesBySuffices; + + deadnix = flake-inputs.deadnix.packages.${pkgs.system}.default; + + excludes = "--exclude ${concatStringsSep " " (map (f: "./${f}") generatedFiles)}"; +in + mkTest { + name = "lint-deadnix"; + src = sourceFilesBySuffices self [".nix"]; + checkInputs = [deadnix]; + checkPhase = '' + mkdir -p $out + deadnix --fail ${excludes} | tee $out/test.log + ''; + } diff --git a/checks/default.nix b/checks/default.nix index 31455ac4..afdf69b0 100644 --- a/checks/default.nix +++ b/checks/default.nix @@ -4,6 +4,14 @@ flake-inputs, }: let inherit (lib) callPackageWith; + + generatedFiles = [ + "home-config/dotfiles/emacs.d/share/templates" + "pkgs/_sources" + "nixos-config/yui/hardware-configuration.nix" + "nixos-config/ren/hardware-configuration.nix" + ]; + mkTest = test: pkgs.stdenv.mkDerivation ({ dontPatch = true; @@ -13,9 +21,10 @@ doCheck = true; } // test); + callPackage = callPackageWith (pkgs // { - inherit flake-inputs mkTest; + inherit flake-inputs mkTest generatedFiles; # Work around `self` technically being a store path when # evaluated as a flake - `builtins.filter` can otherwise not be # called on it. @@ -27,5 +36,6 @@ in { # Linters and formatters alejandra = callPackage ./alejandra.nix {}; + deadnix = callPackage ./deadnix.nix {}; shellcheck = callPackage ./shellcheck.nix {}; } diff --git a/flake.lock b/flake.lock index 5190655c..2286ecae 100644 --- a/flake.lock +++ b/flake.lock @@ -22,6 +22,26 @@ "type": "github" } }, + "deadnix": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1698768041, + "narHash": "sha256-xaaXGzTd+t1GjD2KpiS/c8acv6bXufv/lTN+ACRGVJw=", + "owner": "astro", + "repo": "deadnix", + "rev": "efcd46e3827d1e42e8f2f9cb045dfb34caeb43f5", + "type": "github" + }, + "original": { + "owner": "astro", + "repo": "deadnix", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -136,7 +156,7 @@ }, "flake-utils": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { "lastModified": 1692799911, @@ -188,6 +208,28 @@ "type": "github" } }, + "naersk": { + "inputs": { + "nixpkgs": [ + "deadnix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", + "owner": "nix-community", + "repo": "naersk", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, "nix-gaming": { "inputs": { "flake-parts": "flake-parts", @@ -295,16 +337,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699291058, - "narHash": "sha256-5ggduoaAMPHUy4riL+OrlAZE14Kh7JWX4oLEs22ZqfU=", + "lastModified": 1700538105, + "narHash": "sha256-uZhOCmwv8VupEmPZm3erbr9XXmyg7K67Ul3+Rx2XMe0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "41de143fda10e33be0f47eab2bfe08a50f234267", + "rev": "51a01a7e5515b469886c120e38db325c96694c2f", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.05", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -363,6 +405,22 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1699291058, + "narHash": "sha256-5ggduoaAMPHUy4riL+OrlAZE14Kh7JWX4oLEs22ZqfU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "41de143fda10e33be0f47eab2bfe08a50f234267", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nurpkgs": { "locked": { "lastModified": 1699509948, @@ -403,6 +461,7 @@ "root": { "inputs": { "aagl": "aagl", + "deadnix": "deadnix", "disko": "disko", "fenix": "fenix", "home-manager": "home-manager", @@ -410,7 +469,7 @@ "nix-gaming": "nix-gaming", "nixos-anywhere": "nixos-anywhere", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nixpkgs-unfree": "nixpkgs-unfree", "nixpkgs-unstable": "nixpkgs-unstable", "nurpkgs": "nurpkgs", @@ -473,6 +532,21 @@ "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" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -493,6 +567,24 @@ "repo": "treefmt-nix", "type": "github" } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 98829006..a657c777 100644 --- a/flake.nix +++ b/flake.nix @@ -57,6 +57,7 @@ url = "github:berberman/nvfetcher"; inputs.nixpkgs.follows = "nixpkgs"; }; + deadnix.url = "github:astro/deadnix"; }; outputs = { diff --git a/home-config/config/default.nix b/home-config/config/default.nix index 13e51c36..b294f3f4 100644 --- a/home-config/config/default.nix +++ b/home-config/config/default.nix @@ -1,8 +1,4 @@ { - config, - lib, - ... -}: { imports = [ ./options.nix ./non-nixos.nix diff --git a/home-config/config/desktop/default.nix b/home-config/config/desktop/default.nix index c44196be..155bb7f3 100644 --- a/home-config/config/desktop/default.nix +++ b/home-config/config/desktop/default.nix @@ -1,5 +1,4 @@ { - pkgs, config, lib, ... diff --git a/home-config/config/desktop/dunst.nix b/home-config/config/desktop/dunst.nix index 6a66a4e6..59e2bff7 100644 --- a/home-config/config/desktop/dunst.nix +++ b/home-config/config/desktop/dunst.nix @@ -1,7 +1,6 @@ { config, lib, - pkgs, ... }: let screenHeight = 1080; diff --git a/home-config/config/options.nix b/home-config/config/options.nix index 35d3a8dc..0e9dd552 100644 --- a/home-config/config/options.nix +++ b/home-config/config/options.nix @@ -1,10 +1,5 @@ -{ - config, - lib, - ... -}: let +{lib, ...}: let inherit (lib) mkEnableOption; - cfg = config.custom; in { options.custom = { desktop-environment = mkEnableOption "Set up a stumpwm-based desktop environment"; diff --git a/home-config/config/tty-applications/default.nix b/home-config/config/tty-applications/default.nix index 2975263a..69abd385 100644 --- a/home-config/config/tty-applications/default.nix +++ b/home-config/config/tty-applications/default.nix @@ -1,8 +1,6 @@ { config, - lib, pkgs, - flake-inputs, ... }: { imports = [ diff --git a/home-config/config/tty-applications/emacs.nix b/home-config/config/tty-applications/emacs.nix index 3f072886..5a677ddd 100644 --- a/home-config/config/tty-applications/emacs.nix +++ b/home-config/config/tty-applications/emacs.nix @@ -1,5 +1,4 @@ { - config, pkgs, flake-inputs, ... diff --git a/home-config/default.nix b/home-config/default.nix index 8f21dc16..a06c0655 100644 --- a/home-config/default.nix +++ b/home-config/default.nix @@ -1,6 +1,5 @@ { lib, - pkgs, flake-inputs, ... }: { diff --git a/home-modules/firefox-webapp.nix b/home-modules/firefox-webapp.nix index 6e58e98b..f031aed4 100644 --- a/home-modules/firefox-webapp.nix +++ b/home-modules/firefox-webapp.nix @@ -1,5 +1,4 @@ { - pkgs, config, lib, ... diff --git a/nixos-config/default.nix b/nixos-config/default.nix index e588b1b0..d22c34cb 100644 --- a/nixos-config/default.nix +++ b/nixos-config/default.nix @@ -1,6 +1,5 @@ { lib, - config, pkgs, flake-inputs, ... diff --git a/nixos-config/ren/default.nix b/nixos-config/ren/default.nix index b6cf0eee..e8124959 100644 --- a/nixos-config/ren/default.nix +++ b/nixos-config/ren/default.nix @@ -1,8 +1,4 @@ -{ - lib, - flake-inputs, - ... -}: { +{flake-inputs, ...}: { imports = [ flake-inputs.impermanence.nixosModules.impermanence flake-inputs.disko.nixosModules.disko diff --git a/nixos-config/yui/nvidia.nix b/nixos-config/yui/nvidia.nix index 659ba2e2..7ef2f93a 100644 --- a/nixos-config/yui/nvidia.nix +++ b/nixos-config/yui/nvidia.nix @@ -64,7 +64,7 @@ # Downgrade to 0.5.0 because 1.2.2 doesn't currently work on nvidia # (for me) xdg.portal.extraPortals = lib.mkOverride 49 [ - (pkgs.xdg-desktop-portal-hyprland.overrideAttrs (old: { + (pkgs.xdg-desktop-portal-hyprland.overrideAttrs (_old: { version = "0.5.0"; src = pkgs.fetchFromGitHub { owner = "hyprwm"; diff --git a/pkgs/applications/deepfilternet.nix b/pkgs/applications/deepfilternet.nix index 04670962..a9de2451 100644 --- a/pkgs/applications/deepfilternet.nix +++ b/pkgs/applications/deepfilternet.nix @@ -21,7 +21,7 @@ rustc = toolchain; }; - hdf5-12 = hdf5.overrideAttrs (old: { + hdf5-12 = hdf5.overrideAttrs (_old: { version = "1.12.2"; src = fetchurl { diff --git a/pkgs/applications/emacs/default.nix b/pkgs/applications/emacs/default.nix index 1a643624..9c9451b4 100644 --- a/pkgs/applications/emacs/default.nix +++ b/pkgs/applications/emacs/default.nix @@ -6,10 +6,7 @@ emacsPackagesFor, emacsMacport, emacs, - runCommand, runCommandLocal, - fetchurl, - lzip, }: let emacsPlatform = if hostPlatform.isDarwin @@ -25,7 +22,7 @@ ''; }; - overrides = self: super: { + overrides = _self: super: { dashboard = super.dashboard.overrideAttrs (_old: { patches = [ # See https://github.com/emacs-dashboard/emacs-dashboard/issues/81 @@ -37,7 +34,7 @@ emacsPkgs = (emacsPackagesFor emacsPlatform).overrideScope' overrides; # Compute the list of use-package-d packages. - package-list = runCommand "package-list" {buildInputs = [emacsPkgs.emacs];} '' + package-list = runCommandLocal "package-list" {buildInputs = [emacsPkgs.emacs];} '' HOME=/tmp SCANNING_PACKAGES=true emacs --batch --quick \ -L ${emacsPkgs.use-package}/share/emacs/site-lisp/elpa/use-package-* \ -L ${emacsPkgs.bind-key}/share/emacs/site-lisp/elpa/bind-key-* \ @@ -54,7 +51,7 @@ emacsPkgs.emacs.pkgs.withPackages (epkgs: map (package: builtins.getAttr package epkgs) required-packages); - compiled-dotfiles = runCommand "compiled-init" {buildInputs = [custom-emacs];} '' + compiled-dotfiles = runCommandLocal "compiled-init" {buildInputs = [custom-emacs];} '' cp -r '${self}/home-config/dotfiles/emacs.d/' "$out" chmod -R u+w "$out" diff --git a/pkgs/configuration/phosphor-icons.nix b/pkgs/configuration/phosphor-icons.nix index 4dd285a5..7f481758 100644 --- a/pkgs/configuration/phosphor-icons.nix +++ b/pkgs/configuration/phosphor-icons.nix @@ -1,8 +1,6 @@ { - lib, sources, stdenv, - fetchFromGitHub, }: stdenv.mkDerivation { inherit (sources.phosphor-icons) pname version src;