containers/apps/ci-os/flake.nix

153 lines
4.5 KiB
Nix
Raw Normal View History

2024-11-03 20:28:20 +00:00
{
description = "CI-OS - the Continuous Integration OS";
2024-11-03 20:28:20 +00:00
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
2024-12-30 20:50:06 +00:00
git-sv.url = "git+https://code.252.no/pub/git-sv";
2024-11-03 20:28:20 +00:00
};
outputs = { self, nixpkgs, flake-utils, git-sv, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
lib = nixpkgs.lib;
# imports from flakes
gitSvPkg = git-sv.defaultPackage.${system};
# include a few helper functions
pkgs-local = import ./packages { inherit pkgs lib gitSvPkg; };
# Define a path to the templates directory
templates = builtins.path { path = ./templates; };
in
{
# Define the flake apps
apps = {
flux-local = flake-utils.lib.mkApp { drv = pkgs-local.flux-local; };
flux-diff = flake-utils.lib.mkApp { drv = pkgs-local.flux-diff; };
merge-diff = flake-utils.lib.mkApp { drv = pkgs-local.merge-diff; };
forgejo-comment = flake-utils.lib.mkApp { drv = pkgs-local.forgejo-comment; };
forgejo-release = flake-utils.lib.mkApp { drv = pkgs-local.forgejo-release; };
forgejo-label = flake-utils.lib.mkApp { drv = pkgs-local.forgejo-label; };
};
2024-11-03 20:28:20 +00:00
packages = {
build-image = pkgs.dockerTools.buildImageWithNixDb {
2024-12-30 20:50:06 +00:00
name = "code.252.no/pub/ci-os";
2024-11-03 20:28:20 +00:00
tag = "latest";
copyToRoot = pkgs.buildEnv {
name = "image-root";
pathsToLink = [ "/bin" "/etc" ];
2024-11-03 20:28:20 +00:00
ignoreCollisions = true;
paths = with pkgs; [
# kubernetes
chart-testing
kubernetes-helm
kubernetes-polaris
fluxcd
pluto
skopeo
pkgs-local.flux-local
pkgs-local.flux-diff
pkgs-local.merge-diff
pkgs-local.forgejo-comment
pkgs-local.forgejo-release
pkgs-local.forgejo-label
2024-12-30 20:50:06 +00:00
# code
#codeql
nodePackages.eslint
eslint_d
# repository tooling
gitSvPkg
2024-12-30 20:50:06 +00:00
git-lfs
gnupg
2024-11-03 20:28:20 +00:00
coreutils-full
gnugrep
gawk
findutils
python312Full
2024-11-03 20:28:20 +00:00
docker
bash
cacert
coreutils
curl
jq
yq
jo
2024-11-03 20:28:20 +00:00
gawk
gitFull
git-lfs
gnused
gnutar
gzip
nixVersions.stable
nodejs
openssh
sudo
wget
xz
zstd
# Add Git configuration
(pkgs.writeTextFile {
name = "gitconfig";
destination = "/etc/gitconfig";
text = ''
[user]
name = "ci-os[bot]"
email = "noreply@252.no"
'';
})
2024-11-03 20:28:20 +00:00
(pkgs.writeTextFile {
name = "nix.conf";
destination = "/etc/nix/nix.conf";
text = ''
accept-flake-config = true
experimental-features = nix-command flakes
'';
})
];
};
extraCommands = ''
# for /usr/bin/env
mkdir usr
ln -s ../bin usr/bin
# make sure /tmp exists
mkdir -m 1777 tmp
# need a HOME
mkdir -vp root
# Copy templates into the image at /templates
mkdir -p var/ci-os/templates
cp -r ${templates} var/ci-os/templates
2024-11-03 20:28:20 +00:00
'';
2024-11-03 20:28:20 +00:00
config = {
Cmd = [ "/bin/bash" ];
2024-11-03 20:28:20 +00:00
Env = [
"NIX_PATH=nixpkgs=${nixpkgs}"
"LANG=en_US.UTF-8"
2024-11-03 20:28:20 +00:00
"ENV=/etc/profile.d/nix.sh"
"BASH_ENV=/etc/profile.d/nix.sh"
"NIX_BUILD_SHELL=/bin/bash"
"PAGER=cat"
"PATH=/usr/bin:/bin"
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
"USER=root"
];
};
};
};
}
);
}