-
Notifications
You must be signed in to change notification settings - Fork 57
/
flake.nix
90 lines (74 loc) · 2.71 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
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils = { url = "github:numtide/flake-utils"; };
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, pre-commit-hooks, nixpkgs, flake-utils, treefmt-nix }:
flake-utils.lib.eachDefaultSystem (system:
let
# Current Version of Morph
# TODO: this sucks...
version = "dev";
pkgs = (import nixpkgs) { inherit system; };
# Eval the treefmt modules from ./treefmt.nix
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in {
# for `nix fmt`
formatter = treefmtEval.config.build.wrapper;
# for `nix flake check`
checks = {
formatting = treefmtEval.config.build.check self;
build = self.packages.${system}.morph;
pre-commit-check = let
# some treefmt formatters are not supported in pre-commit-hooks we
# filter them out for now.
toFilter = [ "yamlfmt" ];
filterFn = n: _v: (!builtins.elem n toFilter);
treefmtFormatters =
pkgs.lib.mapAttrs (_n: v: { inherit (v) enable; })
(pkgs.lib.filterAttrs filterFn (import ./treefmt.nix).programs);
in pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = treefmtFormatters;
};
};
# Acessible through 'nix develop' or 'nix-shell' (legacy)
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
inputsFrom = [ self.packages.${system}.morph ];
};
packages = rec {
default = morph;
morph = pkgs.buildGoModule rec {
name = "morph-unstable-${version}";
inherit version;
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
ldflags = [
"-X main.version=${version}"
"-X main.assetRoot=${placeholder "lib"}"
];
vendorHash = "sha256-zQlMtbXgrH83zrcIoOuFhb2tYCeQ1pz4UQUvRIsLMCE==";
postInstall = ''
mkdir -p $lib
cp -v ./data/*.nix $lib
'';
outputs = [ "out" "lib" ];
meta = {
homepage = "https://github.com/DBCDK/morph";
description = "Morph is a NixOS host manager written in Golang.";
mainProgram = "morph";
};
};
};
});
}