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

89 lines
2.4 KiB
Nix
Raw Normal View History

2023-11-27 12:33:52 +00:00
{
2023-11-27 12:34:49 +00:00
description = "staxman";
2023-11-27 12:33:52 +00:00
inputs = {
2024-04-01 10:53:46 +00:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
2023-11-27 12:34:49 +00:00
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-crate2nix = {
2023-11-29 14:39:54 +00:00
url = "github:nix-community/crate2nix";
2023-11-27 12:33:52 +00:00
flake = false;
};
};
outputs =
2023-11-27 12:34:49 +00:00
inputs @ { self
2023-11-27 12:33:52 +00:00
, nixpkgs
2023-11-27 12:34:49 +00:00
, flake-parts
, rust-overlay
, rust-crate2nix
, ...
}: flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
];
flake = {
nixosModules.default = import ./nixos.nix self;
2023-11-27 12:33:52 +00:00
};
2023-11-27 12:34:49 +00:00
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; };
2023-11-27 12:33:52 +00:00
2023-11-27 12:34:49 +00:00
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";
2024-03-30 21:23:07 +00:00
buildInputs = [ 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" \
2024-03-30 21:44:24 +00:00
--set NIX_PATH "nixpkgs=${pkgs.path}" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.arion pkgs.docker-client pkgs.nix ]}
'';
};
2023-11-27 12:34:49 +00:00
in
rec {
packages = {
staxman = wrappedPackage;
2023-11-27 12:34:49 +00:00
default = packages.staxman;
};
2023-11-29 16:29:24 +00:00
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo-watch
clang
arion
docker-client
2023-11-29 16:29:24 +00:00
];
};
2023-11-27 12:33:52 +00:00
};
2023-11-27 12:34:49 +00:00
};
}