Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: don't instantiate nixpkgs in flake + cleanup vm test
Browse files Browse the repository at this point in the history
getchoo committed Nov 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6c10aec commit d0c74e6
Showing 3 changed files with 21 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-vm.yml
Original file line number Diff line number Diff line change
@@ -25,4 +25,4 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Run VM
run: nix build -Lv .#tests.x86_64-linux.modules
run: nix build -Lv .#checks.x86_64-linux.module-vm-test
43 changes: 15 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
};
};

outputs = { self, nixpkgs, home-manager, ... }@inputs:
outputs = { self, nixpkgs, ... }@inputs:
let
systems = [
"x86_64-linux"
@@ -21,20 +21,7 @@

inherit (nixpkgs) lib;

forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgsFor.${s});
nixpkgsFor = lib.genAttrs systems (system: import nixpkgs { inherit system; });

nixosLib = import (nixpkgs + "/nixos/lib") { };
runTestFor = system: test: nixosLib.runTest {
imports = [ test ];

hostPkgs = nixpkgsFor.${system};

_module.args = {
catppuccin = self;
inherit nixpkgs home-manager;
};
};
forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s});

sources = pkgs:
let
@@ -44,6 +31,10 @@
builtins.mapAttrs (_: p: p.src) 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 { inherit inputs sources; };
@@ -52,7 +43,7 @@

packages = forAllSystems (pkgs:
let
mkEval = module: lib.evalModules {
eval = module: lib.evalModules {
modules = [
module
{
@@ -64,27 +55,23 @@
];
};

mkDoc = name: options:
mkDoc = name: module:
let
doc = pkgs.nixosOptionsDoc {
options = lib.filterAttrs (n: _: n != "_module") options;
options = lib.filterAttrs (n: _: n != "_module") (eval module).options;
documentType = "none";
revision = if self ? rev then builtins.substring 0 7 self.rev else "dirty";
revision = builtins.substring 0 7 self.rev or "dirty";
};
in
pkgs.runCommand "${name}-module-doc.md" { } ''
cat ${doc.optionsCommonMark} > $out
'';

hmEval = mkEval self.homeManagerModules.catppuccin;
nixosEval = mkEval self.nixosModules.catppuccin;
in
rec {
nixos-doc = mkDoc "nixos" nixosEval.options;
home-manager-doc = mkDoc "home-manager" hmEval.options;
default = home-manager-doc;
});
{
nixos-doc = mkDoc "nixos" self.nixosModules.catppuccin;
home-manager-doc = mkDoc "home-manager" self.homeManagerModules.catppuccin;

tests.x86_64-linux.modules = runTestFor "x86_64-linux" ./test.nix;
default = self.packages.${pkgs.system}.home-manager-doc;
});
};
}
10 changes: 5 additions & 5 deletions test.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ home-manager
, catppuccin
{ self
, inputs
, ...
}:
let
@@ -21,8 +21,8 @@ in

nodes.machine = { lib, ... }: {
imports = [
catppuccin.nixosModules.catppuccin
home-manager.nixosModules.default
self.nixosModules.catppuccin
inputs.home-manager.nixosModules.default
common
];

@@ -37,7 +37,7 @@ in

home-manager.users.test = {
imports = [
catppuccin.homeManagerModules.catppuccin
self.homeManagerModules.catppuccin
];

inherit (common) catppuccin;

0 comments on commit d0c74e6

Please sign in to comment.