mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
enhance nix-shell and add CI
This commit is contained in:
parent
ffaa63af55
commit
c3fa598922
7 changed files with 99 additions and 41 deletions
2
.envrc
Normal file
2
.envrc
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
watch_file devshell.toml flake.nix
|
||||||
|
use flake || use nix
|
||||||
19
.github/workflows/nix-flake.yml
vendored
Normal file
19
.github/workflows/nix-flake.yml
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.3.4
|
||||||
|
- uses: cachix/install-nix-action@v13
|
||||||
|
with:
|
||||||
|
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210429_d15a196/install
|
||||||
|
|
||||||
|
- run: echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf
|
||||||
|
- name: Run Nix Flake Check
|
||||||
|
run: nix flake check
|
||||||
|
|
||||||
|
- name: Check Nix parsing
|
||||||
|
run: nix-shell --command "evalnix"
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
language: nix
|
|
||||||
script:
|
|
||||||
- nix eval -f ./ci.nix --arg release.e2e false test-check
|
|
||||||
33
flake.lock
generated
33
flake.lock
generated
|
|
@ -1,5 +1,36 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"devshell-flake": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1620641550,
|
||||||
|
"narHash": "sha256-o359KdI/LNiPL6EbirONff2MOvZHtZr9MgYx3R9oVFk=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "devshell",
|
||||||
|
"rev": "a47493423092f6c4c0a7eb605a7cd515a77db4a8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "devshell",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1606424373,
|
||||||
|
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1605370193,
|
"lastModified": 1605370193,
|
||||||
|
|
@ -32,6 +63,8 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"devshell-flake": "devshell-flake",
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
flake.nix
21
flake.nix
|
|
@ -4,10 +4,12 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||||
|
devshell-flake.url = "github:numtide/devshell";
|
||||||
|
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs = { self, nixpkgs, flake-utils, devshell-flake, flake-compat }:
|
||||||
{ nixosModules = import ./modules; }
|
{ modules = import ./modules; }
|
||||||
//
|
//
|
||||||
(flake-utils.lib.eachDefaultSystem
|
(flake-utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
|
|
@ -16,12 +18,20 @@
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [
|
overlays = [
|
||||||
self.overlay
|
self.overlay
|
||||||
|
devshell-flake.overlay
|
||||||
];
|
];
|
||||||
config = { };
|
config = {
|
||||||
|
allowUnsupportedSystem = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
devShell = import ./shell.nix { inherit system pkgs; };
|
devShell = with pkgs; devshell.mkShell
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(devshell.importTOML ./devshell.toml)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
packages = flake-utils.lib.flattenTree {
|
packages = flake-utils.lib.flattenTree {
|
||||||
inherit (pkgs)
|
inherit (pkgs)
|
||||||
|
|
@ -41,7 +51,8 @@
|
||||||
nixosPath = "${nixpkgs}/nixos";
|
nixosPath = "${nixpkgs}/nixos";
|
||||||
};
|
};
|
||||||
# up to date versions of their nixpkgs equivalents
|
# up to date versions of their nixpkgs equivalents
|
||||||
kubernetes = prev.callPackage ./pkgs/applications/networking/cluster/kubernetes { };
|
kubernetes = prev.callPackage ./pkgs/applications/networking/cluster/kubernetes
|
||||||
|
{ };
|
||||||
kubectl = prev.callPackage ./pkgs/applications/networking/cluster/kubectl { };
|
kubectl = prev.callPackage ./pkgs/applications/networking/cluster/kubectl { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
# nixos-k8s implements nixos kubernetes testing runtime
|
# nixos-k8s implements nixos kubernetes testing runtime
|
||||||
|
|
||||||
{
|
{ nixosPath
|
||||||
nixosPath
|
|
||||||
, config
|
, config
|
||||||
, pkgs
|
, pkgs
|
||||||
, lib
|
, lib
|
||||||
|
|
@ -16,12 +15,12 @@ let
|
||||||
kubeconfig = "/etc/${config.services.kubernetes.pki.etcClusterAdminKubeconfig}";
|
kubeconfig = "/etc/${config.services.kubernetes.pki.etcClusterAdminKubeconfig}";
|
||||||
|
|
||||||
# how we differ from the standard configuration of mkKubernetesBaseTest
|
# how we differ from the standard configuration of mkKubernetesBaseTest
|
||||||
extraConfiguration = { config, pkgs, lib, nodes, ...}: {
|
extraConfiguration = { config, pkgs, lib, nodes, ... }: {
|
||||||
virtualisation.memorySize = mkDefault 2048;
|
virtualisation.memorySize = mkDefault 2048;
|
||||||
networking = {
|
networking = {
|
||||||
nameservers = ["10.0.0.254"];
|
nameservers = [ "10.0.0.254" ];
|
||||||
firewall = {
|
firewall = {
|
||||||
trustedInterfaces = ["docker0" "cni0"];
|
trustedInterfaces = [ "docker0" "cni0" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.kubernetes = {
|
services.kubernetes = {
|
||||||
|
|
@ -58,6 +57,7 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
machine1.succeed("${testing.testScript} --kube-config=${kubeconfig}")
|
machine1.succeed("${testing.testScript} --kube-config=${kubeconfig}")
|
||||||
|
|
|
||||||
30
shell.nix
30
shell.nix
|
|
@ -1,17 +1,13 @@
|
||||||
{
|
(import
|
||||||
system ? builtins.currentSystem,
|
(
|
||||||
pkgs,
|
let
|
||||||
}:
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
let
|
in
|
||||||
devshellGitRev = "709fe4d04a9101c9d224ad83f73416dce71baf21";
|
fetchTarball {
|
||||||
|
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||||
devshellSrc = fetchTarball {
|
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||||
url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz";
|
}
|
||||||
sha256 = "1px9cqfshfqs1b7ypyxch3s3ymr4xgycy1krrcg7b97rmmszvsqr";
|
)
|
||||||
};
|
{
|
||||||
|
src = ./.;
|
||||||
devshell = import devshellSrc { inherit system pkgs; };
|
}).shellNix
|
||||||
|
|
||||||
in
|
|
||||||
devshell.fromTOML ./devshell.toml
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue