devcontainers: init

This commit is contained in:
Gabriel Arazas 2024-10-26 18:35:21 +08:00
parent cc55563eb2
commit 0997a95234
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
6 changed files with 96 additions and 0 deletions

View File

@ -51,5 +51,8 @@
devPackages = { devPackages = {
inherit (import ../../docs { inherit pkgs; }) website; inherit (import ../../docs { inherit pkgs; }) website;
}; };
# All of the typical devcontainers to be used.
devcontainers = import ../../devcontainers { inherit pkgs; };
}; };
} }

View File

@ -0,0 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
let inherit (pkgs) callPackage;
in {
rustBackend = callPackage ./rust-backend.nix { };
jsBackend = callPackage ./js-backend.nix { };
}

View File

@ -0,0 +1,13 @@
{ dockerTools, buildEnv, nodejs, bun, pnpm }:
dockerTools.buildImage {
name = "js-backend";
copyToRoot = buildEnv {
name = "js-backend-root";
paths = [ nodejs bun pnpm ];
pathsToLink = [ "/bin" "/share" "/etc" "/lib" ];
};
config.Cmd = [ "/bin/bash" ];
}

View File

@ -0,0 +1,32 @@
{ dockerTools, buildEnv, rustc, cargo, rust-bindgen, rust-analyzer, nodejs, bash
, meson, ninja, pkg-config }:
dockerTools.buildImage {
name = "rust-backend";
copyToRoot = buildEnv {
name = "rust-backend-root";
paths = [
bash
cargo
rust-bindgen
rust-analyzer
rustc
nodejs
meson
ninja
pkg-config
];
pathsToLink = [ "/bin" "/etc" "/lib" "/share" ];
};
runAsRoot = ''
mkdir -p /data
'';
config = {
Cmd = [ "/bin/bash" ];
WorkingDir = "/data";
Volumes."/data" = { };
};
}

View File

@ -8,6 +8,7 @@
imports = [ imports = [
./images.nix ./images.nix
./devpackages.nix ./devpackages.nix
./devcontainers.nix
./disko-configurations.nix ./disko-configurations.nix
./deploy-rs-nodes.nix ./deploy-rs-nodes.nix
./home-configurations.nix ./home-configurations.nix

View File

@ -0,0 +1,40 @@
{ config, lib, flake-parts-lib, ... }:
let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption;
in {
options = {
flake = mkSubmoduleOptions {
devContainers = lib.mkOption {
type = with lib.types; lazyAttrsOf (attrsOf package);
default = { };
description = ''
An attribute set of per-system packages intended to be consumed for
development environments.
'';
};
};
perSystem = mkPerSystemOption {
options = {
devContainers = lib.mkOption {
type = with lib.types; attrsOf package;
default = { };
description = ''
An attribute set of per-system packages intended to be consumed for
development environments.
'';
};
};
};
};
config = {
flake.devContainers = lib.mapAttrs (k: v: v.devContainers)
(lib.filterAttrs (k: v: v.devContainers != { }) config.allSystems);
perInput = system: flake:
lib.optionalAttrs (flake ? devContainers.${system}) {
devContainers = flake.devContainers.${system};
};
};
}