-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[READY] - nix: refactor and update #625
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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
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,117 +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 | ||
''; | ||
}; | ||
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\\] "; | ||
} |
Empty file.
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you run
nix flake check
it will evaluate all the code in the repo, even nixos configurations and build all derivations under thechecks
output.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, but I think itll have an issue running all tests due to the need for qemu in github actions