2021-09-10 00:42:56 +03:00
|
|
|
{
|
2022-02-22 11:00:32 +03:00
|
|
|
description = "A framework for 2nix tools";
|
2021-09-10 00:42:56 +03:00
|
|
|
|
2022-07-12 22:45:29 +03:00
|
|
|
nixConfig = {
|
|
|
|
extra-trusted-public-keys = "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=";
|
|
|
|
extra-substituters = "https://nix-community.cachix.org";
|
|
|
|
};
|
|
|
|
|
2021-09-10 00:42:56 +03:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
2021-11-11 11:11:17 +03:00
|
|
|
|
2022-11-19 07:16:59 +03:00
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
2023-02-18 22:06:01 +03:00
|
|
|
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
2022-11-19 07:16:59 +03:00
|
|
|
|
2023-03-24 07:04:04 +03:00
|
|
|
flake-compat.url = "github:edolstra/flake-compat";
|
|
|
|
flake-compat.flake = false;
|
|
|
|
|
2022-03-07 09:57:22 +03:00
|
|
|
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
|
|
|
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2023-08-28 17:47:15 +03:00
|
|
|
nix-unit.url = "github:adisbladis/nix-unit";
|
|
|
|
nix-unit.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
nix-unit.inputs.flake-parts.follows = "flake-parts";
|
|
|
|
|
2022-06-05 20:59:19 +03:00
|
|
|
devshell = {
|
|
|
|
url = "github:numtide/devshell";
|
|
|
|
flake = false;
|
|
|
|
};
|
2021-09-10 00:42:56 +03:00
|
|
|
};
|
|
|
|
|
2021-11-06 07:38:04 +03:00
|
|
|
outputs = {
|
|
|
|
self,
|
2022-06-05 20:59:19 +03:00
|
|
|
devshell,
|
2022-11-19 07:16:59 +03:00
|
|
|
flake-parts,
|
2021-11-06 07:38:04 +03:00
|
|
|
nixpkgs,
|
2022-03-07 09:57:22 +03:00
|
|
|
pre-commit-hooks,
|
|
|
|
...
|
2022-03-07 13:12:07 +03:00
|
|
|
} @ inp: let
|
2023-07-19 15:33:11 +03:00
|
|
|
l = nixpkgs.lib // builtins;
|
2022-03-07 13:12:07 +03:00
|
|
|
|
2022-10-15 01:05:42 +03:00
|
|
|
inputs = inp;
|
|
|
|
|
2022-11-19 07:16:59 +03:00
|
|
|
perSystem = {
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
system,
|
2023-08-28 17:47:15 +03:00
|
|
|
inputs',
|
2022-11-19 07:16:59 +03:00
|
|
|
...
|
2023-07-19 15:33:11 +03:00
|
|
|
}: {
|
|
|
|
apps = {
|
|
|
|
# passes through extra flags to treefmt
|
|
|
|
format.type = "app";
|
|
|
|
format.program = let
|
|
|
|
path = l.makeBinPath [
|
|
|
|
pkgs.alejandra
|
|
|
|
pkgs.python3.pkgs.black
|
|
|
|
];
|
|
|
|
in
|
|
|
|
l.toString
|
|
|
|
(pkgs.writeScript "format" ''
|
|
|
|
export PATH="${path}"
|
|
|
|
${pkgs.treefmt}/bin/treefmt --clear-cache "$@"
|
|
|
|
'');
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
2022-11-20 09:03:09 +03:00
|
|
|
|
2023-07-19 15:33:11 +03:00
|
|
|
# a dev shell for working on dream2nix
|
|
|
|
# use via 'nix develop . -c $SHELL'
|
|
|
|
devShells = let
|
|
|
|
makeDevshell = import "${inp.devshell}/modules" pkgs;
|
|
|
|
mkShell = config:
|
|
|
|
(makeDevshell {
|
|
|
|
configuration = {
|
|
|
|
inherit config;
|
|
|
|
imports = [];
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
2023-07-19 15:33:11 +03:00
|
|
|
})
|
|
|
|
.shell;
|
|
|
|
in rec {
|
|
|
|
default = dream2nix-shell;
|
|
|
|
dream2nix-shell = mkShell {
|
|
|
|
devshell.name = "dream2nix-devshell";
|
|
|
|
|
2023-09-20 23:03:03 +03:00
|
|
|
packages =
|
|
|
|
[
|
|
|
|
pkgs.alejandra
|
|
|
|
pkgs.mdbook
|
|
|
|
(pkgs.python3.withPackages (ps: [
|
|
|
|
pkgs.python3.pkgs.black
|
|
|
|
]))
|
|
|
|
]
|
|
|
|
++ (l.optionals pkgs.stdenv.isLinux [
|
|
|
|
inputs'.nix-unit.packages.nix-unit
|
|
|
|
]);
|
2023-07-19 15:33:11 +03:00
|
|
|
|
|
|
|
commands =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
package = pkgs.treefmt;
|
|
|
|
category = "formatting";
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# using linux is highly recommended as cntr is amazing for debugging builds
|
|
|
|
++ l.optional pkgs.stdenv.isLinux {
|
|
|
|
package = pkgs.cntr;
|
|
|
|
category = "debugging";
|
|
|
|
};
|
|
|
|
|
|
|
|
devshell.startup = {
|
|
|
|
preCommitHooks.text = self.checks.${system}.pre-commit-check.shellHook;
|
|
|
|
dream2nixEnv.text = ''
|
|
|
|
export NIX_PATH=nixpkgs=${nixpkgs}
|
|
|
|
'';
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
2022-06-05 20:59:19 +03:00
|
|
|
};
|
2023-07-19 15:33:11 +03:00
|
|
|
};
|
2022-11-19 07:16:59 +03:00
|
|
|
|
2023-07-19 15:33:11 +03:00
|
|
|
checks = {
|
|
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
hooks = {
|
|
|
|
treefmt = {
|
|
|
|
enable = true;
|
|
|
|
name = "treefmt";
|
|
|
|
pass_filenames = false;
|
|
|
|
entry = l.toString (pkgs.writeScript "treefmt" ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
2023-07-19 15:57:59 +03:00
|
|
|
export PATH="$PATH:${l.makeBinPath [
|
|
|
|
pkgs.alejandra
|
|
|
|
pkgs.python3.pkgs.black
|
|
|
|
]}"
|
2023-07-19 15:33:11 +03:00
|
|
|
${pkgs.treefmt}/bin/treefmt --clear-cache --fail-on-change
|
|
|
|
'');
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
2022-06-19 11:20:55 +03:00
|
|
|
};
|
2022-03-07 13:26:06 +03:00
|
|
|
};
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
2022-06-13 22:27:05 +03:00
|
|
|
|
2023-07-19 15:33:11 +03:00
|
|
|
packages = {
|
|
|
|
docs =
|
|
|
|
pkgs.runCommand
|
|
|
|
"dream2nix-docs"
|
|
|
|
{nativeBuildInputs = [pkgs.bash pkgs.mdbook];}
|
|
|
|
''
|
|
|
|
bash -c "
|
|
|
|
errors=$(mdbook build -d $out ${./.}/docs |& grep ERROR)
|
|
|
|
if [ \"$errors\" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
"
|
|
|
|
'';
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2023-02-18 22:06:01 +03:00
|
|
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
2022-11-20 09:03:09 +03:00
|
|
|
imports = [
|
2023-07-19 16:48:14 +03:00
|
|
|
./modules/flake-parts/all-modules.nix
|
2023-09-04 01:45:08 +03:00
|
|
|
./pkgs/fetchPipMetadata/flake-module.nix
|
2022-11-20 09:03:09 +03:00
|
|
|
];
|
2022-11-19 07:16:59 +03:00
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"aarch64-darwin"
|
|
|
|
];
|
2023-07-19 15:33:11 +03:00
|
|
|
inherit perSystem;
|
2022-11-19 07:16:59 +03:00
|
|
|
};
|
2021-09-10 00:42:56 +03:00
|
|
|
}
|