1
0
Files
nix-project-template/flake.nix
stubbfelnewpc 146b6b54d1 init
2022-11-01 13:41:22 +00:00

73 lines
2.2 KiB
Nix

{
description = "template flake";
inputs.nixpkgs.url = "nixpkgs/nixos-22.05-small";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
rec {
packages = forAllSystems (system:
{
default = nixpkgsFor.${system}.stdenv.mkDerivation {
name = "hello";
src = self;
buildPhase = "echo nothing todo";
installPhase = "mkdir -p $out/bin; install -t $out/bin src/hello.sh";
};
});
apps = forAllSystems (system:
let
updateLockScript = nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
nix --experimental-features 'nix-command flakes' build
'';
in
{
default = { type = "app"; program = "${packages.${system}.default}/bin/hello.sh"; };
devTasks = {
updateFlakeLock = { type = "app"; program = "${updateLockScript}/bin/update_flake_lock.sh"; };
};
});
devShells = forAllSystems (system:
{
default = nixpkgsFor.${system}.mkShell {
name = "dev-shell";
packages = [ ];
shellHook = ''
alias nixe="nix --experimental-features 'nix-command flakes'"
'';
};
});
hydraJobs = {
tarball = nixpkgsFor.x86_64-linux.releaseTools.sourceTarball rec {
name = "example.sh";
src = self;
version = "0.0.1";
officialRelease = true;
bootstrapBuildInputs = [ ];
distPhase = ''
mkdir $out/tarballs
tar -czvf $out/tarballs/${name}-${version}.tar.gz *
'';
};
runCommandHook = {
recurseForDerivations = { };
example = forAllSystems (system:
nixpkgsFor.${system}.writeShellScriptBin "example_hook.sh" ''
echo foo
''
);
};
};
};
}