1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-23 08:02:21 +03:00

imp: separate devshell into subflake (don't dirty top-level flake inputs)

This commit is contained in:
David Arnold 2022-03-23 16:42:00 -05:00
parent 396b04b62b
commit 5b33c4baef
No known key found for this signature in database
GPG Key ID: 0318D822BAC965CC
8 changed files with 686 additions and 151 deletions

11
.envrc Normal file
View File

@ -0,0 +1,11 @@
#! /bin/sh
# reload when these files change
watch_file devshell/flake.nix
watch_file devshell/flake.lock
{
# shell gc root dir
mkdir -p "$(direnv_layout_dir)"
eval "$(nix print-dev-env ./devshell\#default --no-update-lock-file --no-write-lock-file --profile $(direnv_layout_dir)/flake-profile)"
}

415
devshell/flake.lock Normal file
View File

@ -0,0 +1,415 @@
{
"nodes": {
"blank": {
"locked": {
"lastModified": 1625557891,
"narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=",
"owner": "divnix",
"repo": "blank",
"rev": "5a5d2684073d9f563072ed07c871d577a6c614a8",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "blank",
"type": "github"
}
},
"deploy": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"main",
"latest"
],
"utils": "utils"
},
"locked": {
"lastModified": 1632822684,
"narHash": "sha256-lt7eayYmgsD5OQwpb1XYfHpxttn43bWo7G7hIJs+zJw=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "9a02de4373e0ec272d08a417b269a28ac8b961b4",
"type": "github"
},
"original": {
"owner": "serokell",
"repo": "deploy-rs",
"type": "github"
}
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1647857022,
"narHash": "sha256-Aw70NWLOIwKhT60MHDGjgWis3DP3faCzr6ap9CSayek=",
"owner": "numtide",
"repo": "devshell",
"rev": "0a5ff74dacb9ea22614f64e61aeb3ca0bf0e7311",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"devshell_2": {
"locked": {
"lastModified": 1637575296,
"narHash": "sha256-ZY8YR5u8aglZPe27+AJMnPTG6645WuavB+w0xmhTarw=",
"owner": "numtide",
"repo": "devshell",
"rev": "0e56ef21ba1a717169953122c7415fa6a8cd2618",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1627913399,
"narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils-plus": {
"inputs": {
"flake-utils": "flake-utils_3"
},
"locked": {
"lastModified": 1639385028,
"narHash": "sha256-oqorKz3mwf7UuDJwlbCEYCB2LfcWLL0DkeCWhRIL820=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "be1be083af014720c14f3b574f57b6173b4915d0",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"main",
"nixlib"
]
},
"locked": {
"lastModified": 1637917557,
"narHash": "sha256-3u5bLyGn5NUG3RJA7/v1Bqa/QCFGqp/01Bh/4REf9m4=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "4daff26495ca9ac67476cba8cf15c3e36d91ab18",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-21.11",
"repo": "home-manager",
"type": "github"
}
},
"latest": {
"locked": {
"lastModified": 1638198142,
"narHash": "sha256-plU9b8r4St6q4U7VHtG9V7oF8k9fIpfXl/KDaZLuY9k=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8a308775674e178495767df90c419425474582a1",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"main": {
"inputs": {
"blank": "blank",
"deploy": "deploy",
"devshell": "devshell_2",
"flake-compat": "flake-compat_2",
"flake-utils-plus": "flake-utils-plus",
"home-manager": "home-manager",
"latest": "latest",
"nixlib": "nixlib",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs_2",
"std": "std"
},
"locked": {
"narHash": "sha256-DSQeol3hCIM0ZaSAebmrLHnXcszDy9XScIOCHwEjY6c=",
"path": "../.",
"type": "path"
},
"original": {
"path": "../.",
"type": "path"
}
},
"nixlib": {
"locked": {
"lastModified": 1641688481,
"narHash": "sha256-6L+EU12xLDHby7y8elgFtRKVBxix+7qV8DhVgXqrKZo=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f697717b3d3a074ffc16c8c8227504f0db292886",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixlib_2": {
"locked": {
"lastModified": 1641688481,
"narHash": "sha256-6L+EU12xLDHby7y8elgFtRKVBxix+7qV8DhVgXqrKZo=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f697717b3d3a074ffc16c8c8227504f0db292886",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib_2",
"nixpkgs": [
"main",
"blank"
]
},
"locked": {
"lastModified": 1637655461,
"narHash": "sha256-kXZPbclN3gKwjhp2/RYFDFpAsSBwzX1iLF4EcnHZsPQ=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "05a3eb158a9c7746a5d463726d7f7cccf07500e4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1638222206,
"narHash": "sha256-Zds9H5WB+hBjWhag5yWWDDfYOtsAZKa+Hj23bjrmbZI=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b1cd9a32c2d877d3ae8f17203cc7895272eec688",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1647350163,
"narHash": "sha256-OcMI+PFEHTONthXuEQNddt16Ml7qGvanL3x8QOl2Aao=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3eb07eeafb52bcbf02ce800f032f18d666a9498d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1647350163,
"narHash": "sha256-OcMI+PFEHTONthXuEQNddt16Ml7qGvanL3x8QOl2Aao=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3eb07eeafb52bcbf02ce800f032f18d666a9498d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils_2",
"main": "main",
"nixpkgs": "nixpkgs_4"
}
},
"std": {
"inputs": {
"nixpkgs": "nixpkgs_3",
"yants": "yants"
},
"locked": {
"lastModified": 1647235919,
"narHash": "sha256-fO4dlRO0zeZtzY1QF7iLatx81jena6QP7HZEA83AJ8E=",
"owner": "divnix",
"repo": "std",
"rev": "133fb0c1cc8d0d477a3d339971ef09fa57a60fd3",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "std",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"yants": {
"inputs": {
"nixpkgs": [
"main",
"std",
"nixpkgs"
]
},
"locked": {
"lastModified": 1645126146,
"narHash": "sha256-XQ1eg4gzXoc7Tl8iXak1uCt3KnsTyxqPtLE+vOoDnrQ=",
"owner": "divnix",
"repo": "yants",
"rev": "77df2be1b3cce9f571c6cf451f786b266a6869cc",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "yants",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

145
devshell/flake.nix Normal file
View File

@ -0,0 +1,145 @@
{
description = "Digga (formerly DevOS) devshell";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.main.url = "path:../.";
outputs = inputs:
inputs.flake-utils.lib.eachSystem ["x86_64-linux" "x86_64-darwin"] (
system: let
inherit
(inputs.main.inputs.std.deSystemize system inputs)
main devshell nixpkgs ;
inherit
(main.inputs.std.deSystemize system inputs.main.inputs)
std ;
withCategory = category: attrset: attrset // { inherit category; };
utils = withCategory "utils";
docs = withCategory "docs";
makeDocs = {
name = "make-docs";
help = "Execute the docs creating jobs and place the results in ./doc";
command = ''
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceTopLevel" \
&& cp result "$PRJ_ROOT/doc/api-reference.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference.md"
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceChannels" \
&& cp result "$PRJ_ROOT/doc/api-reference-channels.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-channels.md"
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceHome" \
&& cp result "$PRJ_ROOT/doc/api-reference-home.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-home.md"
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceDevshell" \
&& cp result "$PRJ_ROOT/doc/api-reference-devshell.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-devshell.md"
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceNixos" \
&& cp result "$PRJ_ROOT/doc/api-reference-nixos.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-nixos.md"
'';
};
test = type: name: withCategory "tests" {
name = "check-${name}";
help = "Checks ${name} ${type}";
command = ''
set -e
# set -x
diggaurl=
lockfile_updated=1
lockfile_present=1
tempdigga="\"path:$PRJ_ROOT\""
cleanup() {
if is $lockfile_present; then
git checkout -- flake.lock
elif is $lockfile_updated; then
git rm -f flake.lock
fi
# ensure: restore input
[ -z $diggaurl ] || ${nixpkgs.legacyPackages.gnused}/bin/sed -i "s|$tempdigga|$diggaurl|g" flake.nix
}
digga_fixture() {
# ensure: replace input
diggaurl=$({ grep -o '"github:divnix/digga.*"' flake.nix || true; })
[ -z $diggaurl ] || ${nixpkgs.legacyPackages.gnused}/bin/sed -i "s|$diggaurl|$tempdigga|g" flake.nix
}
trap_err() {
local ret=$?
cleanup
echo -e \
"\033[1m\033[31m""exit $ret: \033[0m\033[1m""command [$BASH_COMMAND] failed""\033[0m"
}
is () { [ "$1" -eq "0" ]; }
trap 'trap_err' ERR
# --------------------------------------------------------------------------------
cd $PRJ_ROOT/${type}/${name}
digga_fixture
test -f flake.lock && lockfile_present=$? || true
${nixpkgs.legacyPackages.nixUnstable}/bin/nix flake lock --update-input digga "$@"; lockfile_updated=$?;
${nixpkgs.legacyPackages.nixUnstable}/bin/nix flake show "$@"
${nixpkgs.legacyPackages.nixUnstable}/bin/nix flake check "$@"
cleanup
'';
};
in {
devShells.default = devshell.legacyPackages.mkShell ( { extraModulesPath, ... }: {
name = "Digga (formerly DevOS)";
imports = [
"${extraModulesPath}/git/hooks.nix"
std.std.devshellProfiles.default
];
git.hooks = {
enable = true;
pre-commit.text = builtins.readFile ./pre-commit.sh;
};
cellsFrom = "./nix";
packages = [
# formatters
nixpkgs.legacyPackages.alejandra
nixpkgs.legacyPackages.nodePackages.prettier
nixpkgs.legacyPackages.shfmt
nixpkgs.legacyPackages.editorconfig-checker
];
commands = [
(utils { package = nixpkgs.legacyPackages.treefmt; })
(utils {
command = "git rm --ignore-unmatch -f $PRJ_ROOT/{tests,examples}/*/flake.lock";
help = "Remove all lock files";
name = "rm-locks";
})
(utils {
name = "evalnix";
help = "Check Nix parsing";
command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null";
})
(test "examples" "devos")
(test "examples" "groupByConfig")
(test "examples" "hmOnly")
(test "examples" "all" // { command = "check-devos && check-groupByConfig && check-hmOnly"; })
(docs { package = nixpkgs.legacyPackages.mdbook; })
(docs makeDocs)
];
}
);
}
);
}

25
devshell/pre-commit.sh Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(${git}/bin/git hash-object -t tree /dev/null)
fi
diff="git diff-index --name-only --cached $against --diff-filter d"
all_files=($($diff))
# Format the entire tree.
treefmt
# check editorconfig
editorconfig-checker -- "${all_files[@]}"
if [[ $? != '0' ]]; then
printf "%b\n" \
"\nCode is not aligned with .editorconfig" \
"Review the output and commit your fixes" >&2
exit 1
fi

View File

@ -221,6 +221,22 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1647350163,
"narHash": "sha256-OcMI+PFEHTONthXuEQNddt16Ml7qGvanL3x8QOl2Aao=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3eb07eeafb52bcbf02ce800f032f18d666a9498d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"blank": "blank",
@ -232,7 +248,27 @@
"latest": "latest",
"nixlib": "nixlib",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"std": "std"
}
},
"std": {
"inputs": {
"nixpkgs": "nixpkgs_2",
"yants": "yants"
},
"locked": {
"lastModified": 1647235919,
"narHash": "sha256-fO4dlRO0zeZtzY1QF7iLatx81jena6QP7HZEA83AJ8E=",
"owner": "divnix",
"repo": "std",
"rev": "133fb0c1cc8d0d477a3d339971ef09fa57a60fd3",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "std",
"type": "github"
}
},
"utils": {
@ -249,6 +285,27 @@
"repo": "flake-utils",
"type": "github"
}
},
"yants": {
"inputs": {
"nixpkgs": [
"std",
"nixpkgs"
]
},
"locked": {
"lastModified": 1645126146,
"narHash": "sha256-XQ1eg4gzXoc7Tl8iXak1uCt3KnsTyxqPtLE+vOoDnrQ=",
"owner": "divnix",
"repo": "yants",
"rev": "77df2be1b3cce9f571c6cf451f786b266a6869cc",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "yants",
"type": "github"
}
}
},
"root": "root",

View File

@ -10,6 +10,7 @@
nixpkgs.url = "github:nixos/nixpkgs/release-21.11";
latest.url = "github:nixos/nixpkgs/nixos-unstable";
nixlib.url = "github:nix-community/nixpkgs.lib";
std.url = "github:divnix/std";
blank.url = "github:divnix/blank";
deploy.url = "github:serokell/deploy-rs";
@ -131,7 +132,6 @@
# system-space and pass sytem and input to each file
jobs = polyfillOutput ./jobs;
checks = polyfillOutput ./checks;
devShell = polyfillOutput ./shell.nix;
};
}

149
shell.nix
View File

@ -1,149 +0,0 @@
{ system ? builtins.currentSystem
, inputs ? (import ./.).inputs
}:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
devshell = import inputs.devshell { inherit pkgs system; };
withCategory = category: attrset: attrset // { inherit category; };
utils = withCategory "utils";
docs = withCategory "docs";
makeDocs = {
name = "make-docs";
help = "Execute the docs creating jobs and place the results in ./doc";
command = ''
nix build "$PRJ_ROOT#jobs.${pkgs.system}.mkApiReferenceTopLevel" \
&& cp result "$PRJ_ROOT/doc/api-reference.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference.md"
nix build "$PRJ_ROOT#jobs.${pkgs.system}.mkApiReferenceChannels" \
&& cp result "$PRJ_ROOT/doc/api-reference-channels.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-channels.md"
nix build "$PRJ_ROOT#jobs.${pkgs.system}.mkApiReferenceHome" \
&& cp result "$PRJ_ROOT/doc/api-reference-home.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-home.md"
nix build "$PRJ_ROOT#jobs.${pkgs.system}.mkApiReferenceDevshell" \
&& cp result "$PRJ_ROOT/doc/api-reference-devshell.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-devshell.md"
nix build "$PRJ_ROOT#jobs.${pkgs.system}.mkApiReferenceNixos" \
&& cp result "$PRJ_ROOT/doc/api-reference-nixos.md" \
&& chmod 755 "$PRJ_ROOT//doc/api-reference-nixos.md"
'';
};
test = type: name: withCategory "tests" {
name = "check-${name}";
help = "Checks ${name} ${type}";
command = ''
set -e
# set -x
diggaurl=
lockfile_updated=1
lockfile_present=1
tempdigga="\"path:$PRJ_ROOT\""
cleanup() {
if is $lockfile_present; then
git checkout -- flake.lock
elif is $lockfile_updated; then
git rm -f flake.lock
fi
# ensure: restore input
[ -z $diggaurl ] || ${pkgs.gnused}/bin/sed -i "s|$tempdigga|$diggaurl|g" flake.nix
}
digga_fixture() {
# ensure: replace input
diggaurl=$({ grep -o '"github:divnix/digga.*"' flake.nix || true; })
[ -z $diggaurl ] || ${pkgs.gnused}/bin/sed -i "s|$diggaurl|$tempdigga|g" flake.nix
}
trap_err() {
local ret=$?
cleanup
echo -e \
"\033[1m\033[31m""exit $ret: \033[0m\033[1m""command [$BASH_COMMAND] failed""\033[0m"
}
is () { [ "$1" -eq "0" ]; }
trap 'trap_err' ERR
# --------------------------------------------------------------------------------
cd $PRJ_ROOT/${type}/${name}
digga_fixture
test -f flake.lock && lockfile_present=$? || true
${pkgs.nixUnstable}/bin/nix flake lock --update-input digga "$@"; lockfile_updated=$?;
${pkgs.nixUnstable}/bin/nix flake show "$@"
${pkgs.nixUnstable}/bin/nix flake check "$@"
cleanup
'';
};
in
devshell.mkShell {
name = "digga";
packages = with pkgs; [
fd
nixpkgs-fmt
nixUnstable
];
env = [
{
name = "NIX_CONFIG";
value =
''extra-experimental-features = nix-command flakes
extra-substituters = https://nrdxp.cachix.org https://nix-community.cachix.org
extra-trusted-public-keys = nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs='';
}
];
# tempfix: remove when merged https://github.com/numtide/devshell/pull/123
devshell.startup.load_profiles = pkgs.lib.mkForce (pkgs.lib.noDepEntry ''
# PATH is devshell's exorbitant privilige:
# fence against its pollution
_PATH=''${PATH}
# Load installed profiles
for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do
# If that folder doesn't exist, bash loves to return the whole glob
[[ -f "$file" ]] && source "$file"
done
# Exert exorbitant privilige and leave no trace
export PATH=''${_PATH}
unset _PATH
'');
commands = [
(utils {
command = "git rm --ignore-unmatch -f $PRJ_ROOT/{tests,examples}/*/flake.lock";
help = "Remove all lock files";
name = "rm-locks";
})
(utils {
name = "fmt";
help = "Check Nix formatting";
command = "nixpkgs-fmt \${@} $PRJ_ROOT";
})
(utils {
name = "evalnix";
help = "Check Nix parsing";
command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null";
})
(test "examples" "devos")
(test "examples" "groupByConfig")
(test "examples" "hmOnly")
(test "examples" "all" // { command = "check-devos && check-groupByConfig && check-hmOnly"; })
(docs { package = pkgs.mdbook; })
(docs makeDocs)
];
}

31
treefmt.toml Normal file
View File

@ -0,0 +1,31 @@
# One CLI to format the code tree - https://github.com/numtide/treefmt
[formatter.nix]
command = "alejandra"
includes = ["*.nix"]
[formatter.prettier]
command = "prettier"
options = ["--write"]
includes = [
"*.css",
"*.html",
"*.js",
"*.json",
# "*.jsx",
"*.md",
"*.mdx",
"*.scss",
"*.ts",
"*.yaml",
]
[formatter.shell]
command = "shfmt"
options = [
"-i",
"2", # indent 2
"-s", # simplify the code
"-w", # write back to the file
]
includes = ["*.sh"]