115 lines
2.8 KiB
Nix
115 lines
2.8 KiB
Nix
# SPDX-FileCopyrightText: 2023 Gregor Kleen
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
{
|
|
inputs = {
|
|
nixpkgs = {
|
|
type = "github";
|
|
owner = "NixOS";
|
|
repo = "nixpkgs";
|
|
ref = "22.11";
|
|
};
|
|
|
|
flake-parts = {
|
|
type = "github";
|
|
owner = "hercules-ci";
|
|
repo = "flake-parts";
|
|
};
|
|
|
|
pre-commit-hooks-nix = {
|
|
type = "github";
|
|
owner = "cachix";
|
|
repo = "pre-commit-hooks.nix";
|
|
};
|
|
};
|
|
|
|
outputs = inputs @ {
|
|
self,
|
|
nixpkgs,
|
|
flake-parts,
|
|
pre-commit-hooks-nix,
|
|
...
|
|
}:
|
|
flake-parts.lib.mkFlake
|
|
{inherit inputs;}
|
|
({...}: {
|
|
imports = [
|
|
flake-parts.flakeModules.easyOverlay
|
|
pre-commit-hooks-nix.flakeModule
|
|
];
|
|
|
|
config = {
|
|
systems = ["x86_64-linux"];
|
|
|
|
perSystem = {
|
|
system,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}: {
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [poetry reuse];
|
|
shellHook = ''
|
|
${config.pre-commit.installationScript}
|
|
'';
|
|
};
|
|
|
|
pre-commit = {
|
|
settings.hooks = {
|
|
reuse = {
|
|
enable = true;
|
|
pass_filenames = false;
|
|
entry = "${config.pre-commit.pkgs.reuse}/bin/reuse lint";
|
|
};
|
|
black.enable = true;
|
|
alejandra.enable = true;
|
|
};
|
|
};
|
|
|
|
packages = {
|
|
default = config.packages.k8s-gitlab-borg;
|
|
|
|
k8s-gitlab-borg = with pkgs.poetry2nix;
|
|
mkPoetryApplication {
|
|
projectDir = cleanPythonSources {src = ./.;};
|
|
|
|
overrides = overrides.withDefaults (self: super: {
|
|
urllib3 = super.urllib3.overridePythonAttrs (oldAttrs: {
|
|
buildInputs = (oldAttrs.buildInputs or []) ++ [super.hatchling];
|
|
});
|
|
});
|
|
|
|
nativeBuildInputs = with pkgs; [makeWrapper];
|
|
|
|
postInstall = ''
|
|
wrapProgram $out/bin/k8s-gitlab-borg \
|
|
${pkgs.lib.escapeShellArgs [
|
|
"--prefix"
|
|
"PATH"
|
|
":"
|
|
(pkgs.lib.makeBinPath (with pkgs; [borgbackup]))
|
|
]}
|
|
'';
|
|
|
|
meta.mainProgram = "k8s-gitlab-borg";
|
|
};
|
|
};
|
|
|
|
overlayAttrs = {
|
|
inherit (config.packages) k8s-gitlab-borg;
|
|
};
|
|
};
|
|
|
|
flake.nixosModules = {
|
|
k8s-gitlab-borg = import ./k8s-gitlab-borg.nix;
|
|
|
|
default = {config, ...}: {
|
|
imports = with self.nixosModules; [k8s-gitlab-borg];
|
|
|
|
config.nixpkgs.overlays = [self.overlays.default];
|
|
};
|
|
};
|
|
};
|
|
});
|
|
}
|