Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add subflake for development & testing #64

Merged
merged 1 commit into from
Dec 16, 2023
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
10 changes: 7 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion .github/workflows/test-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/update-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
63 changes: 63 additions & 0 deletions dev/flake.lock

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

66 changes: 66 additions & 0 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -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;
});
};
}
47 changes: 0 additions & 47 deletions flake.lock

This file was deleted.

68 changes: 3 additions & 65 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
});
};
}
6 changes: 3 additions & 3 deletions test.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ self
{ ctp
, inputs
, ...
}:
Expand All @@ -21,7 +21,7 @@ in

nodes.machine = { lib, ... }: {
imports = [
self.nixosModules.catppuccin
ctp.nixosModules.catppuccin
inputs.home-manager.nixosModules.default
common
];
Expand All @@ -37,7 +37,7 @@ in

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

inherit (common) catppuccin;
Expand Down