-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathflake.nix
More file actions
81 lines (80 loc) · 2.35 KB
/
flake.nix
File metadata and controls
81 lines (80 loc) · 2.35 KB
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
{
description = "Dev Flake for Modem-dev's Hunk";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
bun2nix.url = "github:nix-community/bun2nix";
bun2nix.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-substituters = [
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
outputs = {
self,
nixpkgs,
bun2nix,
...
}: let
lib = nixpkgs.lib;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs supportedSystems;
perSystem = forAllSystems (
system: let
pkgs = import nixpkgs {
inherit system;
};
hunk = pkgs.callPackage ./nix/package.nix {
bun2nix = bun2nix.packages.${system}.default;
};
updateBunLock = pkgs.writeShellScriptBin "hunk-update-bun-lock" ''
set -euo pipefail
${bun2nix.packages.${system}.default}/bin/bun2nix -o nix/bun.lock.nix -c ../ "$@"
if [ -s nix/bun.lock.nix ] && [ "$(${pkgs.coreutils}/bin/tail -c 1 nix/bun.lock.nix)" != "" ]; then
printf '\n' >> nix/bun.lock.nix
fi
'';
in {
packages = {
inherit hunk;
default = hunk;
};
apps = {
default = {
type = "app";
program = "${hunk}/bin/hunk";
meta.description = "Run Hunk";
};
update-bun-lock = {
type = "app";
program = "${updateBunLock}/bin/hunk-update-bun-lock";
meta.description = "Regenerate nix/bun.lock.nix with the flake-pinned bun2nix";
};
};
devShells = {
default = pkgs.callPackage ./nix/devShell.nix {};
};
}
);
systemOutput = name: lib.mapAttrs (_: value: value.${name}) perSystem;
in {
packages = systemOutput "packages";
apps = systemOutput "apps";
devShells = systemOutput "devShells";
homeManagerModules = {
hunk = import ./nix/home-manager.nix;
default = {pkgs, ...}: {
imports = [self.homeManagerModules.hunk];
programs.hunk.package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
};
};
}