Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
uses: DeterminateSystems/nix-installer-action@main
- name: Update Site
run: |
mkdir -p ./_site
nix run --show-trace ./docs -- ./_site
nix run --show-trace ./ci#docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ jobs:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

# Everything we use is already cached anyway by nixpkgs
# Until we actually have that many wrappers, this is not worth it.
# Even with only 1 module changed,
# uploading the delta afterwards is longer than the checks themselves currently.

# - name: Setup Nix cache
# uses: DeterminateSystems/magic-nix-cache-action@main

- name: Run checks
run: nix flake check -Lvv --log-format bar-with-logs
run: nix flake check -Lvv --log-format bar-with-logs ./ci
4 changes: 2 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
- name: Update main lockfile
run: |
nix flake update
- name: Update docs lockfile
- name: Update ci lockfile
run: |
nix flake update --flake ./docs
nix flake update --flake ./ci
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
Expand Down
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ So, if this might be important for your program, you can consider providing a di

# Tests

`nix flake check -Lv`
`nix flake check -Lv ./ci`

# Run Site Generator Locally

`nix run ./ci`

or

`nix run ./ci#docs`

# Writing tests

Expand Down
38 changes: 0 additions & 38 deletions checks/no-module-prefix-in-checks.nix

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion checks/formatting.nix → ci/checks/formatting.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
pkgs.runCommand "formatting-check" { } ''
${
pkgs.lib.getExe self.formatter.${pkgs.stdenv.hostPlatform.system}
} --no-cache --fail-on-change ${../.}
} --no-cache --fail-on-change ${../../.}
touch $out
''
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions ci/checks/no-module-prefix-in-checks.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
pkgs,
self,
}:

let
# Get all check files in checks/ directory
checkFiles = builtins.readDir ./.;

# Filter for .nix files that start with "module-"
checksWithPrefix =
prefix:
pkgs.lib.filter (name: pkgs.lib.hasPrefix prefix name && pkgs.lib.hasSuffix ".nix" name) (
builtins.attrNames checkFiles
);

invalidChecksMod = checksWithPrefix "module-";
invalidChecksWrap = checksWithPrefix "wrapperModule-";

in
pkgs.runCommand "no-module-prefix-in-checks-test" { } ''
echo "Checking that no checks in ci/checks/ directory start with 'module-' or 'wrapperModule-'..."

${
if invalidChecksMod != [ ] then
''
echo "FAIL: The following checks have invalid 'module-' prefix:"
${pkgs.lib.concatMapStringsSep "\n" (name: ''echo " - ${name}"'') invalidChecksMod}
echo ""
echo "Checks starting with 'module-' are reserved for module-specific checks (modules/*/check.nix)."
echo "Please rename these checks to avoid namespace collision."
exit 1
''
else if invalidChecksWrap != [ ] then
''
echo "FAIL: The following checks have invalid 'wrapperModule-' prefix:"
${pkgs.lib.concatMapStringsSep "\n" (name: ''echo " - ${name}"'') invalidChecksWrap}
echo ""
echo "Checks starting with 'wrapperModule-' are reserved for wrapperModule-specific checks (wrapperModules/*/*/check.nix)."
echo "Please rename these checks to avoid namespace collision."
exit 1
''
else
''
echo "SUCCESS: No checks start with 'module-' or 'wrapperModule-' prefixes"
''
}

touch $out
''
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions docs/default.nix → ci/docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ in
src = "${placeholder "out"}/wrappers-lib/intro.md";
build = ''
mkdir -p $out/wrappers-lib
sed 's|# \[nix-wrapper-modules\](https://birdeehub.github.io/nix-wrapper-modules/)|# [nix-wrapper-modules](https://github.com/BirdeeHub/nix-wrapper-modules)|' < '${../README.md}' > "$out/wrappers-lib/intro.md"
sed 's|# \[nix-wrapper-modules\](https://birdeehub.github.io/nix-wrapper-modules/)|# [nix-wrapper-modules](https://github.com/BirdeeHub/nix-wrapper-modules)|' < '${../../README.md}' > "$out/wrappers-lib/intro.md"
'';
}
{
Expand All @@ -124,7 +124,7 @@ in
path = "lib/wlib.md";
src = "${placeholder "out"}/wrappers-lib/wlib.md";
build = ''
${pkgs.nixdoc}/bin/nixdoc --category "" --description '`wlib` main set documentation' --file '${../lib/lib.nix}' --prefix "wlib" >> $out/wrappers-lib/wlib.md
${pkgs.nixdoc}/bin/nixdoc --category "" --description '`wlib` main set documentation' --file '${../../lib/lib.nix}' --prefix "wlib" >> $out/wrappers-lib/wlib.md
'';
}
{
Expand All @@ -133,7 +133,7 @@ in
path = "lib/types.md";
src = "${placeholder "out"}/wrappers-lib/types.md";
build = ''
${pkgs.nixdoc}/bin/nixdoc --category "types" --description '`wlib.types` set documentation' --file '${../lib/types.nix}' --prefix "wlib" >> $out/wrappers-lib/types.md
${pkgs.nixdoc}/bin/nixdoc --category "types" --description '`wlib.types` set documentation' --file '${../../lib/types.nix}' --prefix "wlib" >> $out/wrappers-lib/types.md
'';
}
{
Expand All @@ -142,7 +142,7 @@ in
path = "lib/dag.md";
src = "${placeholder "out"}/wrappers-lib/dag.md";
build = ''
${pkgs.nixdoc}/bin/nixdoc --category "dag" --description '`wlib.dag` set documentation' --file '${../lib/dag.nix}' --prefix "wlib" >> $out/wrappers-lib/dag.md
${pkgs.nixdoc}/bin/nixdoc --category "dag" --description '`wlib.dag` set documentation' --file '${../../lib/dag.nix}' --prefix "wlib" >> $out/wrappers-lib/dag.md
'';
}
];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions docs/flake.lock → ci/flake.lock

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

80 changes: 80 additions & 0 deletions ci/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
description = "Generates the website documentation for the nix-wrapper-modules repository";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/master";
outputs =
{ nixpkgs, self, ... }:
let
inherit (nixpkgs) lib;
forAllSystems = lib.genAttrs lib.platforms.all;
wlib-flake =
pkgs: if pkgs == null then import ./.. { inherit nixpkgs; } else import ./.. { inherit pkgs; };
wlib-flake-nofmt = removeAttrs (wlib-flake null) [ "formatter" ];
wlib = wlib-flake-nofmt.lib;
in
wlib-flake-nofmt
// {
checks = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};

# Load checks from checks/ directory
checkFiles = builtins.readDir ./checks;
importCheck = name: {
name = lib.removeSuffix ".nix" name;
value = import (./checks + "/${name}") {
inherit pkgs;
self = self;
};
};
checksFromDir = builtins.listToAttrs (
map importCheck (builtins.filter (name: lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles))
);

importModuleCheck = prefix: name: value: {
name = "${prefix}-${name}";
value = import value {
inherit pkgs;
self = self;
};
};
checksFromModules = builtins.listToAttrs (
builtins.filter (v: v.value or null != null) (
lib.mapAttrsToList (importModuleCheck "module") (wlib.checks.helper or { })
)
);
checksFromWrapperModules = builtins.listToAttrs (
builtins.filter (v: v.value or null != null) (
lib.mapAttrsToList (importModuleCheck "wrapperModule") (wlib.checks.wrapper or { })
)
);
in
checksFromDir // checksFromModules // checksFromWrapperModules
);
formatter = forAllSystems (
system: (wlib-flake (import nixpkgs { inherit system; })).formatter.${system}
);
packages = forAllSystems (system: {
default = self.packages.${system}.docs;
docs = wlib.evalPackage [
./docs
{
pkgs = import nixpkgs {
inherit system;
config = {
# note: we want the name
# so that config.binName and config.package and config.exePath look nice in docs
# Nothing should build. This is fine...
allowUnfree = true;
allowBroken = true;
allowUnsupportedSystem = true;
};
};
}
];
});
};
}
24 changes: 0 additions & 24 deletions docs/flake.nix

This file was deleted.

51 changes: 11 additions & 40 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
outputs =
{ self, ... }@inputs:
let
fpkgs =
system:
if inputs.pkgs.stdenv.hostPlatform.system or null == system then
inputs.pkgs
else
import (inputs.pkgs.path or inputs.nixpkgs or <nixpkgs>) {
inherit system;
config.allowUnfree = true;
};
lib = inputs.pkgs.lib or inputs.nixpkgs.lib or (import "${inputs.nixpkgs or <nixpkgs>}/lib");
forAllSystems = lib.genAttrs lib.platforms.all;
in
{
templates = import ./templates;
lib = import ./lib { inherit lib; };
flakeModules = {
wrappers = ./parts.nix;
Expand Down Expand Up @@ -65,38 +57,17 @@
This output will be replaced with module paths on April 30, 2026
''
) self.wrappers;
formatter = forAllSystems (system: (fpkgs system).nixfmt-tree);
templates = import ./templates;
checks = forAllSystems (
formatter = forAllSystems (
system:
let
pkgs = fpkgs system;

# Load checks from checks/ directory
checkFiles = builtins.readDir ./checks;
importCheck = name: {
name = lib.removeSuffix ".nix" name;
value = import (./checks + "/${name}") {
inherit pkgs;
self = self;
};
};
checksFromDir = builtins.listToAttrs (
map importCheck (builtins.filter (name: lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles))
);

importModuleCheck = name: value: {
name = "module-${name}";
value = import value {
inherit pkgs;
self = self;
};
};
checksFromModules = builtins.listToAttrs (
builtins.filter (v: v.value or null != null) (lib.mapAttrsToList importModuleCheck self.lib.checks)
);
in
checksFromDir // checksFromModules
(
if inputs.pkgs.stdenv.hostPlatform.system or null == system then
inputs.pkgs
else
import (inputs.pkgs.path or inputs.nixpkgs or <nixpkgs>) {
inherit system;
overlays = inputs.pkgs.overlays or [ ];
}
).nixfmt-tree
);
};
}
5 changes: 4 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
lib,
wrappers_dir ? import ../wrapperModules { inherit lib wlib; },
modules_dir ? import ../modules { inherit lib wlib; },
checks ? wrappers_dir.checks or { } // modules_dir.checks or { },
checks ? {
wrapper = wrappers_dir.checks or { };
helper = modules_dir.checks or { };
},
wrapperModules ? wrappers_dir.wrapperModules or { },
modules ? modules_dir.modules or { },
maintainers ? import ../maintainers { inherit lib; },
Expand Down
Loading