feat: add subflake for development & testing (#64)

This commit is contained in:
seth 2023-12-16 18:38:36 -05:00 committed by GitHub
parent cceb51991e
commit 07e54f5b3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 151 additions and 121 deletions

View file

@ -11,10 +11,14 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run formatter
run: nix fmt
run: |
pushd dev/
nix fmt
popd
- name: Check for changes
run: git diff --color=always --exit-code

View file

@ -19,10 +19,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
with:
extra_nix_config: "system-features = benchmark big-parallel kvm nixos-test uid-range"
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Run VM
run: nix build -Lv .#checks.x86_64-linux.module-vm-test
run: |
nix build -Lv ./dev#checks.x86_64-linux.module-vm-test

View file

@ -32,7 +32,8 @@ jobs:
echo "rev=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Build doc
run: nix build .#${{ matrix.package }}-doc
run: |
nix build ./dev#${{ matrix.package }}-doc
- name: Update doc
run: cat result > docs/${{ matrix.package }}-options.md

View file

@ -21,8 +21,10 @@ jobs:
- name: Update flake inputs
run: |
pushd dev
nix flake update \
--commit-lock-file --commit-lockfile-summary "chore: update flake inputs"
--commit-lock-file --commit-lockfile-summary "chore: update dev flake inputs"
popd
- name: Update upstream sources
run: |

63
dev/flake.lock Normal file
View file

@ -0,0 +1,63 @@
{
"nodes": {
"call-flake": {
"locked": {
"lastModified": 1699147280,
"narHash": "sha256-bmhE1TmrJG4ba93l9WQTLuYM53kwGQAjYHRvHOeuxWU=",
"owner": "divnix",
"repo": "call-flake",
"rev": "7d993ee93bd35a9e6574ec76d54b7d44087495ad",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "call-flake",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1699368917,
"narHash": "sha256-nUtGIWf86BOkUbtksWtfglvCZ/otP0FTZlQH8Rzc7PA=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "6a8444467c83c961e2f5ff64fb4f422e303c98d3",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1699099776,
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"call-flake": "call-flake",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

66
dev/flake.nix Normal file
View file

@ -0,0 +1,66 @@
{
description = "Soothing pastel theme for Nix";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
call-flake.url = "github:divnix/call-flake";
};
outputs = { self, nixpkgs, call-flake, ... }@inputs:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
inherit (nixpkgs) lib;
forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s});
ctp = call-flake ../.;
in
{
checks = forAllSystems (pkgs: lib.optionalAttrs pkgs.stdenv.isLinux {
module-vm-test = pkgs.nixosTest (import ../test.nix { inherit ctp inputs; });
});
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
packages = forAllSystems (pkgs:
let
eval = module: lib.evalModules {
modules = [
module
{
_module.check = false;
}
];
};
mkDoc = name: module:
let
doc = pkgs.nixosOptionsDoc {
options = lib.filterAttrs (n: _: n != "_module") (eval module).options;
documentType = "none";
revision = builtins.substring 0 8 self.rev or "dirty";
};
in
pkgs.runCommand "${name}-module-doc.md" { } ''
cat ${doc.optionsCommonMark} > $out
'';
in
{
nixos-doc = mkDoc "nixos" ctp.nixosModules.catppuccin;
home-manager-doc = mkDoc "home-manager" ctp.homeManagerModules.catppuccin;
default = self.packages.${pkgs.system}.home-manager-doc;
});
};
}

View file

@ -1,47 +0,0 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698873617,
"narHash": "sha256-FfGFcfbULwbK1vD+H0rslIOfmy4g8f2hXiPkQG3ZCTk=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "48b0a30202516e25d9885525fbb200a045f23f26",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1698611440,
"narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,70 +1,8 @@
{
description = "Soothing pastel theme for Nix";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = _: {
homeManagerModules.catppuccin = import ./modules/home-manager;
nixosModules.catppuccin = import ./modules/nixos;
};
outputs = { self, nixpkgs, ... }@inputs:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
inherit (nixpkgs) lib;
forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s});
in
{
checks = forAllSystems (pkgs: lib.optionalAttrs pkgs.stdenv.isLinux {
module-vm-test = pkgs.nixosTest (import ./test.nix { inherit self inputs; });
});
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
homeManagerModules.catppuccin = import ./modules/home-manager;
nixosModules.catppuccin = import ./modules/nixos;
packages = forAllSystems (pkgs:
let
eval = module: lib.evalModules {
modules = [
module
{
_module = {
check = false;
args.lib = import ./modules/lib/mkExtLib.nix lib;
};
}
];
};
mkDoc = name: module:
let
doc = pkgs.nixosOptionsDoc {
options = lib.filterAttrs (n: _: n != "_module") (eval module).options;
documentType = "none";
revision = builtins.substring 0 8 self.rev or "dirty";
};
in
pkgs.runCommand "${name}-module-doc.md" { } ''
cat ${doc.optionsCommonMark} > $out
'';
in
{
nixos-doc = mkDoc "nixos" self.nixosModules.catppuccin;
home-manager-doc = mkDoc "home-manager" self.homeManagerModules.catppuccin;
default = self.packages.${pkgs.system}.home-manager-doc;
});
};
}

View file

@ -1,4 +1,4 @@
{ self
{ ctp
, inputs
, ...
}:
@ -21,7 +21,7 @@ in
nodes.machine = { lib, ... }: {
imports = [
self.nixosModules.catppuccin
ctp.nixosModules.catppuccin
inputs.home-manager.nixosModules.default
common
];
@ -37,7 +37,7 @@ in
home-manager.users.test = {
imports = [
self.homeManagerModules.catppuccin
ctp.homeManagerModules.catppuccin
];
inherit (common) catppuccin;