mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
devcontainers: init
This commit is contained in:
parent
cc55563eb2
commit
0997a95234
@ -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; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
7
devcontainers/default.nix
Normal file
7
devcontainers/default.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
let inherit (pkgs) callPackage;
|
||||||
|
in {
|
||||||
|
rustBackend = callPackage ./rust-backend.nix { };
|
||||||
|
jsBackend = callPackage ./js-backend.nix { };
|
||||||
|
}
|
13
devcontainers/js-backend.nix
Normal file
13
devcontainers/js-backend.nix
Normal 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" ];
|
||||||
|
}
|
32
devcontainers/rust-backend.nix
Normal file
32
devcontainers/rust-backend.nix
Normal 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" = { };
|
||||||
|
};
|
||||||
|
}
|
@ -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
|
||||||
|
40
modules/flake-parts/devcontainers.nix
Normal file
40
modules/flake-parts/devcontainers.nix
Normal 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};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user