-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
try.nix
46 lines (38 loc) · 1.05 KB
/
try.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
{ pkgs ? import <nixpkgs> {} }:
let
lib = pkgs.lib;
in
pkgs.stdenv.mkDerivation rec {
pname = "hello-nix";
version = "0.1.0";
name = "${pname}-${version}";
src = ./.;
buildInputs = [ pkgs.cowsay ];
nativeBuildInputs = [ pkgs.makeWrapper ];
# Example of using a configuration file
configFile = pkgs.writeText "hello-config.json" ''
{
"greeting": "Hello, Nix!"
}
'';
buildPhase = ''
echo '#!${pkgs.bash}/bin/bash' > hello.sh
echo '${pkgs.cowsay}/bin/cowsay "$(${pkgs.jq}/bin/jq -r .greeting ${configFile})"' >> hello.sh
chmod +x hello.sh
'';
installPhase = ''
mkdir -p $out/bin
cp hello.sh $out/bin/${pname}
'';
fixupPhase = ''
wrapProgram $out/bin/${pname} \
--prefix PATH : ${lib.makeBinPath [ pkgs.cowsay pkgs.jq ]}
'';
meta = with lib; {
description = "A simple Nix package that says hello using cowsay";
homepage = "https://example.com/${pname}";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with maintainers; [ /* your name here */ ];
};
}