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

Minor refinements to options declaration #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "CI"
on:
push:
branches:
- main
pull_request:
jobs:
checks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14]
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.garnix.io?priority=41 https://cache.nixos.org/
- uses: yaxitech/nix-install-pkgs-action@v3
with:
packages: "github:srid/nixci"
- run: nixci build
115 changes: 115 additions & 0 deletions dev/flake.lock

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

32 changes: 32 additions & 0 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
just-flake.url = "github:juspay/just-flake";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.treefmt-nix.flakeModule
];
perSystem = { pkgs, lib, config, ... }: {
treefmt = {
projectRoot = inputs.just-flake;
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
};
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
nixd
];
inputsFrom = [
config.treefmt.build.devShell
];
};
};
};
}
13 changes: 13 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,18 @@
description = "A `flake-parts` module for including `just` in devShell";
outputs = _: {
flakeModule = import ./flake-module.nix;

# https://github.com/srid/nixci
nixci.default = let overrideInputs = { just-flake = ./.; }; in {
dev = {
inherit overrideInputs;
dir = "dev";
};

test = {
inherit overrideInputs;
dir = "test";
};
};
};
}
2 changes: 1 addition & 1 deletion nix/feature.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
description = ''
The justfile code for importing this feature's justfile.

See https://just.systems/man/en/chapter_53.html
See https://just.systems/man/en/chapter_55.html
'';
default =
if config.enable
Expand Down
6 changes: 3 additions & 3 deletions nix/features.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ in
options.features = {
convco = lib.mkOption {
description = "Add the 'changelog' target calling convco";
type = types.submodule { imports = [ featureMod ]; };
type = featureType;
};
rust = lib.mkOption {
description = "Add 'w' and 'test' targets for running cargo";
type = types.submodule { imports = [ featureMod ]; };
type = featureType;
};
treefmt = lib.mkOption {
description = "Add the 'fmt' target to format source tree using treefmt";
type = types.submodule { imports = [ featureMod ]; };
type = featureType;
};
};

Expand Down
61 changes: 61 additions & 0 deletions test/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
# Since there is no flake.lock file (to avoid incongruent just-flake
# pinning), we must specify revisions for *all* inputs to ensure
# reproducibility.
inputs = {
nixpkgs = { };
flake-parts = { };
just-flake = { };
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.just-flake.flakeModule
];

perSystem = { config, self', pkgs, lib, ... }: {
just-flake = {
commonFileName = "justfile";

features = {
convco.enable = true;
};
};

devShells.test = pkgs.mkShell {
inputsFrom = [
config.just-flake.outputs.devShell
];
};

# Our test
checks.test =
pkgs.runCommandNoCC "test"
{
nativeBuildInputs = with pkgs; [
which
] ++ self'.devShells.test.nativeBuildInputs;
}
''
(
set -x
echo "Testing ..."

which just || \
(echo "just should be in devshell"; exit 2)

${self'.devShells.test.shellHook}

grep -q treefmt justfile && \
(echo "justfile should not import treefmt"; exit 2)

grep -q convco justfile || \
(echo "justfile should import convco"; exit 2)

touch $out
)
'';
};
};
}