Skip to content

Commit

Permalink
build: use flake-parts partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
terlar committed Sep 10, 2024
1 parent 88f6671 commit b672c89
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /bin/sh
export NIX_USER_CONF_FILES="$PWD/nix.conf"
export NIX_USER_CONF_FILES="$PWD/dev/nix.conf"

if nix print-dev-env --help >/dev/null 2>&1; then
use flake ./dev
use flake
else
use nix
fi
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@ jobs:
- name: Check
run: nix flake check

dev-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: DeterminateSystems/nix-installer-action@da36cb69b1c3247ad7a1f931ebfd954a1105ef14 # v14
with:
nix-package-url: https://releases.nixos.org/nix/nix-2.18.2/nix-2.18.2-x86_64-linux.tar.xz
extra-conf: |
http-connections = 50
max-jobs = auto
diagnostic-endpoint: ''

- uses: cachix/cachix-action@ad2ddac53f961de1989924296a1f236fcfbaa4fc # v15
with:
useDaemon: true
name: terlar
extraPullNames: cuda-maintainers
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Check
run: nix flake check ./dev

build-home-configuration:
strategy:
matrix:
Expand Down
53 changes: 53 additions & 0 deletions dev/flake-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ inputs, ... }:

{
imports = [ inputs.dev-flake.flakeModule ];

dev = {
name = "terlar/nix-config";
rootSrc = ../.;
};

perSystem =
{ pkgs, ... }:
{
treefmt = {
programs.nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
settings.formatter.fish = {
command = pkgs.writeShellApplication {
name = "fish_indent-wrapper";
runtimeInputs = [
pkgs.fish
pkgs.findutils
];
text = ''
fish_indent --check "$@" 2>&1 | xargs --no-run-if-empty fish_indent --write || true
'';
};
includes = [ "*.fish" ];
};
};

devshells.default = {
commands = [
{
name = "repl";
command = ''
exec nix repl --file "$PRJ_ROOT/dev/repl.nix" "$@"
'';
help = "Development REPL";
}
];

env = [
{
name = "NIX_USER_CONF_FILES";
value = toString ./nix.conf;
}
];
};
};
}
21 changes: 0 additions & 21 deletions dev/flake.lock

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

63 changes: 2 additions & 61 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
description = "Development environment";
description = "Dependencies for development purposes";

inputs = {
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
dev-flake = {
url = "github:terlar/dev-flake";
inputs = {
Expand All @@ -15,66 +11,11 @@
};
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";

# Compatibility
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};

outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];

imports = [ inputs.dev-flake.flakeModule ];

dev = {
name = "terlar/nix-config";
rootSrc = ../.;
};

perSystem =
{ pkgs, ... }:
{
treefmt = {
programs.nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
settings.formatter.fish = {
command = pkgs.writeShellApplication {
name = "fish_indent-wrapper";
runtimeInputs = [
pkgs.fish
pkgs.findutils
];
text = ''
fish_indent --check "$@" 2>&1 | xargs --no-run-if-empty fish_indent --write || true
'';
};
includes = [ "*.fish" ];
};
};

devshells.default = {
commands = [
{
name = "repl";
command = ''
exec nix repl --file "$PRJ_ROOT/dev/repl.nix" "$@"
'';
help = "Development REPL";
}
];

env = [
{
name = "NIX_USER_CONF_FILES";
value = toString ./nix.conf;
}
];
};
};
};
outputs = _: { };
}
14 changes: 14 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,26 @@
systems = [ "x86_64-linux" ];

imports = [
flake-parts.flakeModules.partitions

./modules/flake/home-manager.nix
./configurations/home/terje
./configurations/nixos/kong
./configurations/nixos/installer-yubikey
];

partitionedAttrs = {
checks = "dev";
devShells = "dev";
};

partitions.dev = {
extraInputsFlake = ./dev;
module = {
imports = [ ./dev/flake-module.nix ];
};
};

flake = {
lib = import ./lib.nix { inherit (nixpkgs) lib; };

Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ in
(import (fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ./dev; }).shellNix
}) { src = ./.; }).shellNix

0 comments on commit b672c89

Please sign in to comment.