Skip to content

Commit

Permalink
Add dev flake and use nixCI
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Jul 19, 2023
1 parent a0c93bd commit 95642d9
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 11 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake ./dev
18 changes: 8 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v18
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: cachix/cachix-action@v12
with:
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
name: srid
- name: Build 🔨
run: nix run github:srid/nixci
- name: Test example
id: example
run: |
Expand All @@ -28,8 +30,4 @@ jobs:
cd $TEMP_DIR
nix flake init -t $FLAKE
nix develop --override-input mission-control path:${FLAKE} -c , fmt
- name: Flake checks 🧪
run: |
# Because 'nix flake check' is not system-aware
# See https://srid.ca/haskell-template/checks
nix run nixpkgs#sd 'systems = nixpkgs.lib.systems.flakeExposed' 'systems = [ "x86_64-linux" ]' flake.nix
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.direnv
131 changes: 131 additions & 0 deletions dev/flake.lock

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

39 changes: 39 additions & 0 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
mission-control.url = "github:Platonic-Systems/mission-control";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.flake-root.flakeModule
inputs.mission-control.flakeModule
inputs.treefmt-nix.flakeModule
];
perSystem = { pkgs, lib, config, ... }: {
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
};
};
mission-control.scripts = {
fmt = {
description = "Format all Nix files";
exec = config.treefmt.build.wrapper;
};
};
devShells.default = pkgs.mkShell {
# cf. https://zero-to-flakes.com/haskell-flake/devshell#composing-devshells
inputsFrom = [
config.mission-control.devShell
config.treefmt.build.devShell
];
};
};
};
}
14 changes: 13 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
{
description = "A `flake-parts` module for your Nix devshell scripts";
outputs = { self, ... }: {
outputs = { ... }: {
flakeModule = ./nix/flake-module.nix;
templates.default = {
description = "Example flake using mission-control to provide scripts";
path = builtins.path { path = ./example; filter = path: type: baseNameOf path == "flake.nix"; };
};

# Config for https://github.com/srid/nixci
# To run this, `nix run github:srid/nixci`
nixci = let overrideInputs = { "mission-control" = ./.; }; in {
example = {
inherit overrideInputs;
dir = "./example";
};
dev = {
dir = "./dev";
};
};
};
}

0 comments on commit 95642d9

Please sign in to comment.