Skip to content

Commit

Permalink
treewide: Introduce deadnix
Browse files Browse the repository at this point in the history
  • Loading branch information
TLATER committed Nov 23, 2023
1 parent 8656b5c commit 9da8955
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 47 deletions.
12 changes: 5 additions & 7 deletions checks/alejandra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
mkTest,
lib,
alejandra,
generatedFiles,
}: let
inherit (lib) concatStringsSep;
inherit (lib.sources) sourceFilesBySuffices;
excludes = concatStringsSep " " (map (f: "--exclude ./${f}") generatedFiles);
in
mkTest {
name = "lint-alejandra";
src = sourceFilesBySuffices self [".nix"];
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
'';
}
24 changes: 24 additions & 0 deletions checks/deadnix.nix
Original file line number Diff line number Diff line change
@@ -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
'';
}
12 changes: 11 additions & 1 deletion checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -27,5 +36,6 @@
in {
# Linters and formatters
alejandra = callPackage ./alejandra.nix {};
deadnix = callPackage ./deadnix.nix {};
shellcheck = callPackage ./shellcheck.nix {};
}
104 changes: 98 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
url = "github:berberman/nvfetcher";
inputs.nixpkgs.follows = "nixpkgs";
};
deadnix.url = "github:astro/deadnix";
};

outputs = {
Expand Down
4 changes: 0 additions & 4 deletions home-config/config/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
config,
lib,
...
}: {
imports = [
./options.nix
./non-nixos.nix
Expand Down
1 change: 0 additions & 1 deletion home-config/config/desktop/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
pkgs,
config,
lib,
...
Expand Down
1 change: 0 additions & 1 deletion home-config/config/desktop/dunst.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
config,
lib,
pkgs,
...
}: let
screenHeight = 1080;
Expand Down
7 changes: 1 addition & 6 deletions home-config/config/options.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 0 additions & 2 deletions home-config/config/tty-applications/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
config,
lib,
pkgs,
flake-inputs,
...
}: {
imports = [
Expand Down
1 change: 0 additions & 1 deletion home-config/config/tty-applications/emacs.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
config,
pkgs,
flake-inputs,
...
Expand Down
1 change: 0 additions & 1 deletion home-config/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
lib,
pkgs,
flake-inputs,
...
}: {
Expand Down
1 change: 0 additions & 1 deletion home-modules/firefox-webapp.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
pkgs,
config,
lib,
...
Expand Down
1 change: 0 additions & 1 deletion nixos-config/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
lib,
config,
pkgs,
flake-inputs,
...
Expand Down
6 changes: 1 addition & 5 deletions nixos-config/ren/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
lib,
flake-inputs,
...
}: {
{flake-inputs, ...}: {
imports = [
flake-inputs.impermanence.nixosModules.impermanence
flake-inputs.disko.nixosModules.disko
Expand Down
2 changes: 1 addition & 1 deletion nixos-config/yui/nvidia.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/deepfilternet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
rustc = toolchain;
};

hdf5-12 = hdf5.overrideAttrs (old: {
hdf5-12 = hdf5.overrideAttrs (_old: {
version = "1.12.2";

src = fetchurl {
Expand Down
Loading

0 comments on commit 9da8955

Please sign in to comment.