mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2025-03-05 16:36:56 +00:00
29 lines
783 B
Nix
29 lines
783 B
Nix
{ stdenv, lib, runtimeShell }:
|
|
|
|
let
|
|
# Bring fileset functions into scope.
|
|
# See https://nixos.org/manual/nixpkgs/stable/index.html#sec-functions-library-fileset
|
|
inherit (lib.fileset) toSource unions;
|
|
in
|
|
|
|
# Example package in the style that `mkDerivation`-based packages in Nixpkgs are written.
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
name = "hello";
|
|
src = toSource {
|
|
root = ./.;
|
|
fileset = unions [
|
|
./hello.sh
|
|
];
|
|
};
|
|
buildPhase = ''
|
|
# Note that Nixpkgs has builder functions for simple packages
|
|
# like this, but this template avoids it to make for a more
|
|
# complete example.
|
|
substitute hello.sh hello --replace '@shell@' ${runtimeShell}
|
|
cat hello
|
|
chmod a+x hello
|
|
'';
|
|
installPhase = ''
|
|
install -D hello $out/bin/hello
|
|
'';
|
|
})
|