-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7fc4d4
commit 5089efd
Showing
18 changed files
with
241 additions
and
184 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,17 @@ | ||
{ | ||
nixConfig.bash-prompt = "\\[\\033[01;32m\\][nix-flakes \\W] \$\\[\\033[00m\\] "; | ||
|
||
inputs = { | ||
nixpkgs.url = "nixpkgs/nixos-unstable"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; | ||
}; | ||
outputs = { self, nixpkgs, ... }: | ||
let | ||
# System types to support. | ||
supportedSystems = [ "x86_64-linux" ]; | ||
|
||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. | ||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); | ||
|
||
# Nixpkgs instantiated for supported system types. | ||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }); | ||
in | ||
{ | ||
overlays.default = (final: prev: | ||
with final.pkgs; | ||
rec { | ||
scaleTests = callPackage ./nix/tests/allTests.nix { }; | ||
massflash = callPackage ./nix/pkgs/massflash.nix { }; | ||
scaleInventory = callPackage ./nix/pkgs/scaleInventory.nix { }; | ||
}); | ||
|
||
packages = forAllSystems (system: { | ||
inherit (nixpkgsFor.${system}) scaleTests scaleInventory; | ||
}); | ||
|
||
nixosConfigurations = | ||
let | ||
# All scale common modules | ||
system = "x86_64-linux"; | ||
common = | ||
({ modulesPath, ... }: { | ||
imports = [ | ||
./nix/modules/bhyve-image.nix | ||
./nix/machines/_common/users.nix | ||
]; | ||
}); | ||
pkgs = nixpkgsFor.${system}; | ||
in | ||
{ | ||
loghost = nixpkgs.lib.nixosSystem { | ||
inherit system; | ||
modules = [ | ||
common | ||
./nix/machines/loghost.nix | ||
]; | ||
}; | ||
massflash = nixpkgs.lib.nixosSystem { | ||
inherit system pkgs; | ||
modules = [ | ||
({ modulesPath, ... }: { | ||
imports = [ | ||
"${toString modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" | ||
]; | ||
}) | ||
./nix/machines/massflash.nix | ||
]; | ||
}; | ||
coreMaster = nixpkgs.lib.nixosSystem { | ||
inherit system pkgs; | ||
modules = [ | ||
common | ||
./nix/machines/core/master.nix | ||
]; | ||
specialArgs = { inherit self; }; | ||
}; | ||
coreSlave = nixpkgs.lib.nixosSystem { | ||
inherit system pkgs; | ||
modules = [ | ||
common | ||
./nix/machines/core/slave.nix | ||
]; | ||
}; | ||
signs = nixpkgs.lib.nixosSystem { | ||
inherit system pkgs; | ||
modules = [ | ||
common | ||
./nix/machines/signs.nix | ||
]; | ||
}; | ||
}; | ||
|
||
# Like nix-shell | ||
# Good example: https://github.com/tcdi/pgx/blob/master/flake.nix | ||
devShells = forAllSystems | ||
(system: | ||
let | ||
pkgs = nixpkgsFor.${system}; | ||
in | ||
{ | ||
default = import ./shell.nix { inherit pkgs; }; | ||
}); | ||
|
||
checks = | ||
let | ||
pkgs = nixpkgsFor.x86_64-linux; | ||
in | ||
{ | ||
# python tests for the data found in facts | ||
# disabling persistence and cache for py utils to avoid warnings | ||
# since caching is taken care of by nix | ||
pytest-facts = pkgs.runCommand "pytest-facts" { } '' | ||
cp -r ${pkgs.lib.cleanSource self}/* . | ||
cd facts | ||
${pkgs.python3Packages.pylint}/bin/pylint --persistent n *.py | ||
${pkgs.python3Packages.pytest}/bin/pytest -vv -p no:cacheprovider | ||
touch $out | ||
''; | ||
perl-switches = pkgs.runCommand "perl-switches" | ||
{ | ||
buildInputs = [ pkgs.gnumake pkgs.perl ]; | ||
} '' | ||
cp -r ${pkgs.lib.cleanSource self}/* . | ||
cd switch-configuration | ||
make .lint | ||
make .build-switch-configs | ||
touch $out | ||
''; | ||
|
||
}; | ||
outputs = inputs: | ||
inputs.flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = [ "x86_64-linux" "aarch64-linux" ]; | ||
imports = [ | ||
./nix/flake-module.nix | ||
]; | ||
}; | ||
|
||
# Bold green prompt for `nix develop` | ||
# Had to add extra escape chars to each special char | ||
nixConfig.bash-prompt = "\\[\\033[01;32m\\][nix-flakes \\W] \$\\[\\033[00m\\] "; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
perSystem = { pkgs, ... }: | ||
let | ||
scale_python = pkgs.python3.withPackages (p: with p ; [ pytest pylint ipdb ]); | ||
|
||
# Trying to keep these pkg sets separate for later | ||
global = with pkgs; [ | ||
bash | ||
curl | ||
git | ||
jq | ||
kermit | ||
screen | ||
glibcLocales | ||
(pkgs.python3.withPackages (p: with p ; [ pytest pylint ipdb ])) | ||
]; | ||
ansible_sub = [ | ||
pkgs.ansible | ||
pkgs.ansible-lint | ||
]; | ||
openwrt_sub = with pkgs; [ | ||
expect | ||
gomplate | ||
magic-wormhole | ||
tftp-hpa | ||
nettools | ||
unixtools.ping | ||
iperf3 | ||
ncurses | ||
ncurses.dev | ||
pkg-config | ||
gcc | ||
stdenv | ||
]; | ||
network_sub = [ pkgs.perl ]; | ||
in | ||
{ | ||
devShells.default = pkgs.mkShell { | ||
packages = global | ||
++ ansible_sub | ||
++ openwrt_sub | ||
++ network_sub; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
imports = [ | ||
./pkgs/flake-module.nix | ||
./tests/flake-module.nix | ||
./modules/flake-module.nix | ||
./machines/flake-module.nix | ||
./dev/flake-module.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ lib, inputs, ... }: | ||
|
||
let | ||
# All scale common modules | ||
system = "x86_64-linux"; | ||
common = { | ||
imports = [ | ||
inputs.self.nixosModules.bhyve-image | ||
./_common/users.nix | ||
]; | ||
}; | ||
in | ||
{ | ||
flake.nixosConfigurations = | ||
{ | ||
loghost = lib.nixosSystem { | ||
inherit system; | ||
modules = [ | ||
common | ||
./loghost.nix | ||
]; | ||
specialArgs = { inherit inputs; }; | ||
}; | ||
massflash = lib.nixosSystem { | ||
inherit system; | ||
modules = [ | ||
({ modulesPath, ... }: { | ||
imports = [ | ||
"${ toString modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" | ||
]; | ||
}) | ||
./massflash.nix | ||
]; | ||
specialArgs = { inherit inputs; }; | ||
}; | ||
coreMaster = lib.nixosSystem { | ||
inherit system; | ||
modules = [ | ||
common | ||
./core/master.nix | ||
]; | ||
specialArgs = { inherit inputs; }; | ||
}; | ||
coreSlave = lib.nixosSystem { | ||
inherit system; | ||
modules = [ | ||
common | ||
./core/slave.nix | ||
]; | ||
specialArgs = { inherit inputs; }; | ||
}; | ||
signs = lib.nixosSystem { | ||
inherit system; | ||
modules = [ | ||
common | ||
./signs.nix | ||
]; | ||
specialArgs = { inherit inputs; }; | ||
}; | ||
}; | ||
|
||
|
||
} |
Oops, something went wrong.