-
Notifications
You must be signed in to change notification settings - Fork 87
/
flake.nix
98 lines (91 loc) · 2.95 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
systems.url = "github:nix-systems/default";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, systems, treefmt-nix, ... }:
let
# HOWTO keep this package definition up-to-date:
#
# 1. NEW VERSION:
# After the new version is tagged and pushed, update the `version` var to the
# proper value and update the hash. You can use the following command to find
# out the sha256, for example, with version 1.0.3:
# `nix-prefetch-github --rev v1.0.3 laamaa m8c`
#
# 2. NEW DEPENDENCIES:
# Make sure new dependencies are added. Runtime deps go to buildInputs and
# compile-time deps go to nativeBuildInputs. Use the nixpkgs manual for help
pname = "m8c";
version = "1.7.8";
m8c-package =
{ stdenv
, gnumake
, pkg-config
, SDL2
, libserialport
, fetchFromGitHub
}:
stdenv.mkDerivation {
inherit pname version;
src = fetchFromGitHub {
owner = "laamaa";
repo = pname;
rev = "v${version}";
hash = "sha256:0rvc2qsrk7kqk5hnwkh8pya7nc6y7q4i6k8d0rg41jdw0fscsici";
};
installFlags = [ "PREFIX=$(out)" ];
nativeBuildInputs = [ gnumake pkg-config ];
buildInputs = [ SDL2 libserialport ];
};
eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f
(import nixpkgs { inherit system; })
);
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs (_: {
projectRootFile = "flake.nix";
programs = {
clang-format.enable = false; # TODO(pope): Enable and format C code
deadnix.enable = true;
nixpkgs-fmt.enable = true;
statix.enable = true;
};
}));
in
{
packages = eachSystem (pkgs: rec {
m8c-stable = pkgs.callPackage m8c-package { };
m8c-dev = (pkgs.callPackage m8c-package { }).overrideAttrs (_oldAttrs: {
src = ./.;
});
default = m8c-stable;
});
overlays.default = final: _prev: {
inherit (self.packages.${final.system}) m8c-stable m8c-dev;
};
apps = eachSystem (pkgs: rec {
m8c = {
type = "app";
program = "${self.packages.${pkgs.system}.m8c-stable}/bin/m8c";
};
default = m8c;
});
devShells = eachSystem (pkgs: with pkgs; {
default = mkShell {
packages = [
nix-prefetch-github
treefmtEval.${system}.config.build.wrapper
];
inputsFrom = [ self.packages.${system}.m8c-dev ];
};
});
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
};
}