-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
127 lines (114 loc) · 4.24 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
# description = "Description for the project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
flake-parts.url = "github:hercules-ci/flake-parts";
# for the development shell, as the name suggests
devshell.url = "github:numtide/devshell";
# allows filtering files from the sources, prevents rebuilts if, for example, the flake.nix changes
# nix-filter.url = "github:numtide/nix-filter";
# sort-of working "nix build" intergration for node and rust
# dream2nix.url = "github:nix-community/dream2nix";
# for rust toolchain stuff
# rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
# To import a flake module
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
inputs.devshell.flakeModule
# inputs.dream2nix.flakeModuleBeta
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
perSystem = { config, self', inputs', pkgs, system, ... }: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
# dream2nix configuration for builds
# dream2nix.inputs."replaceme" = {
# source = (inputs.nix-filter.lib {
# root = ./.;
# exclude = [
# (inputs.nix-filter.lib.matchExt "nix")
# "flake.lock"
# ".envrc"
# ".secret.envrc"
# ];
# });
# projects = {
# replaceme = {
# # relPath = "/replaceme";
# subsystem = "rust";
# translator = "cargo-lock";
# };
# };
# };
# this exposes things to "nix build .#XXXX"
# the default package could be defined like this:
# packages.default = config.dream2nix.outputs.replaceme.packages.default;
#
# "basic" rust builds without dream2nix
# packages.default = pkgs.rustPlatform.buildRustPackage {
# pname = "replaceme";
# version = "0.1.0";
# src = (inputs.nix-filter.lib {
# root = ./.;
# exclude = [
# (inputs.nix-filter.lib.matchExt "nix")
# "flake.lock"
# ".envrc"
# ".secret.envrc"
# ];
# });
# cargoLock.lockFile = ./Cargo.lock;
# nativeBuildInputs = with pkgs;
# [
# # pkg-config
# rust-bin.stable.latest.default
# ];
# };
#
# packages =
# {
# inherit (config.dream2nix.outputs.frontend.packages) frontend;
# };
packages.default = pkgs.stdenv.mkDerivation {
pname = "simple-formatter";
version = "1.0.0";
src = ./.;
buildInputs = [ pkgs.jq pkgs.yq-go pkgs.gnumake ];
nativeBuildInputs = [ pkgs.makeWrapper ];
installPhase =
''
mkdir -p $out/bin
cp simple-formatter.sh $out/bin/simple-formatter.sh
wrapProgram $out/bin/simple-formatter.sh \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.jq pkgs.yq-go pkgs.gnumake ]}
''
;
};
# overlays can be defined here
# see https://flake.parts/overlays.html
# _module.args.pkgs = import inputs.nixpkgs {
# inherit system;
# overlays = [
# inputs.rust-overlay.overlays.default
# # this pulls in something from another input flake, like nixos-unstable
# # (final: prev: {
# # unstable = inputs.nixpkgs-unstable.legacyPackages.${system};
# # })
# ];
# };
# packages for devshell can be defined here
devshells.default = { packages = with pkgs; [ jq yq-go gnumake ]; };
};
};
}