-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
103 lines (88 loc) · 3.06 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
description = "universal nix: plug-n-play nix with build tooling";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
parts.url = "github:hercules-ci/flake-parts";
parts.inputs.nixpkgs-lib.follows = "nixpkgs";
commit.url = "github:cachix/pre-commit-hooks.nix";
commit.inputs.nixpkgs.follows = "nixpkgs";
# used to bootstrap uninix, not meant to be packaged
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
rust.url = "github:oxalica/rust-overlay";
rust.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, parts, commit, crane, rust, ... } @ proxy:
let
base = nixpkgs.lib // builtins;
inputs = proxy;
perSystem = { self', pkgs, system, inputs', config, ... }:
let
intermediary = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
bootstrap = crane.lib.${system}.overrideToolchain intermediary;
bootstrapArgs = {
pname = "uninix";
version = self.rev or "dirty";
src = bootstrap.cleanCargoSource ./.;
};
artifacts = bootstrap.buildDepsOnly bootstrapArgs;
uninix-bootstrap = bootstrap.buildPackage (bootstrapArgs // { inherit artifacts; });
in
{
apps = {
uninix-bootstrap = {
type = "app";
program = base.getExe self'.packages.uninix-bootstrap;
};
format = {
type = "app";
program =
let path = base.makeBinPath [ pkgs.nixpkgs-fmt ];
in base.toString (pkgs.writeScript "format" ''
export PATH="${path}"
${pkgs.treefmt}/bin/treefmt --clear-cache "$@"
'');
};
};
checks = {
uninix-bootstrap = uninix-bootstrap;
pre-commit-check = commit.lib.${system}.run {
src = ./.;
hooks = {
treefmt = {
enable = true;
name = "treefmt";
pass_filenames = false;
entry = base.toString (pkgs.writeScript "treefmt" ''
#!${pkgs.bash}/bin/bash
export PATH="$PATH:${base.makeBinPath [pkgs.nixpkgs-fmt]}"
${pkgs.treefmt}/bin/treefmt --clear-cache --fail-on-change
'');
};
};
};
};
packages = {
uninix-bootstrap = uninix-bootstrap;
};
# tysm NyCodeGHG for helping with this
# check out her code !
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
rust.overlays.default
];
};
};
in
parts.lib.mkFlake { inherit inputs; } {
imports = [ ./modules/flake-parts/all-modules.nix ];
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
inherit perSystem;
};
}