This repository has been archived on 2024-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
staxman-old/flake.nix
Hamcha e5509561bf
Some checks failed
Build and push Docker image / build-and-publish (push) Has been cancelled
build: try not compiling the entirety of nix
2024-03-30 22:19:58 +01:00

86 lines
2.3 KiB
Nix

{
description = "staxman";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-crate2nix = {
url = "github:nix-community/crate2nix";
flake = false;
};
};
outputs =
inputs @ { self
, nixpkgs
, flake-parts
, rust-overlay
, rust-crate2nix
, ...
}: flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
];
flake = {
nixosModules.default = import ./nixos.nix self;
};
perSystem = { system, pkgs, ... }:
let
overlays = [
(import rust-overlay)
(self: super:
let
toolchain = super.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
rustc = toolchain;
})
];
pkgs = import nixpkgs { inherit system overlays; };
project =
let
crateTools = pkgs.callPackage "${rust-crate2nix}/tools.nix" { inherit pkgs; };
in
import
(crateTools.generatedCargoNix {
name = "staxman";
src = ./.;
})
{
inherit pkgs;
};
# Package with runtime dependencies and environment variable
wrappedPackage = pkgs.stdenv.mkDerivation {
name = "staxman";
buildInputs = [ pkgs.arion pkgs.docker-client pkgs.makeWrapper ];
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
cp ${project.rootCrate.build}/bin/* $out/bin
wrapProgram $out/bin/staxman \
--set STAX_ARION_BIN "${pkgs.arion}/bin/arion" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.arion pkgs.docker-client pkgs.nix ]}
'';
};
in
rec {
packages = {
staxman = wrappedPackage;
default = packages.staxman;
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo-watch
clang
arion
docker-client
];
};
};
};
}