Skip to content

Commit

Permalink
refactor: add requiredInputs check
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Oct 12, 2023
1 parent be75cd7 commit 16510ea
Show file tree
Hide file tree
Showing 17 changed files with 420 additions and 13 deletions.
24 changes: 24 additions & 0 deletions lib/errors/inputsSource.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ lib }:
list:
lib.filter (pair: lib.elem pair.name list) [
{
name = "nixpkgs";
url = "github:nixpkgs/nixpkgs-unstable";
}
{
name = "makes";
url = "github:fluidattacks/makes";
}
{
name = "home-manager";
url = "github:github:nix-community/home-manager";
}
{
name = "microvm";
url = "github:astro/microvm.nix";
}
{
name = "topiary";
url = "github:github:tweag/topiary";
}
]
26 changes: 20 additions & 6 deletions lib/errors/requiredInputs.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{ lib, inputs }:
listNames:
{
lib,
inputs,
super,
}:
inputs': listNames:
let
fondInputs =
if
Expand All @@ -11,11 +15,21 @@ let
else
false
;
msg = lib.concatMapStringsSep " " (m: "${m}") listNames;
msg =
(lib.concatMapStringsSep "\n "
(
{ name, url }:
''
# add `${name}.url = "${url}"` to your flake
${name} = inputs.${name};
''
)
(super.inputsSource listNames)
);

noSysNixpkgs =
if (lib.elem "nixpkgs" listNames) then
if (lib.hasAttr "path" inputs.nixpkgs) then true else false
if (lib.hasAttr "path" inputs'.nixpkgs) then true else false
else
true
;
Expand All @@ -25,7 +39,7 @@ assert lib.assertMsg fondInputs ''
omnibus.lib.addLoadExtender {
load.inputs = {
inherit ${msg};
${msg}
# you can also see the full inputs list at
# https://github.com/GTrunSec/omnibus/blob/main/local/lock/flake.nix#L1
Expand All @@ -42,4 +56,4 @@ assert lib.assertMsg noSysNixpkgs ''
};
}
'';
inputs
inputs'
5 changes: 5 additions & 0 deletions lib/exporter/flakeOutputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ let
in
{
inherit (outputs) srvos;

units = {
inherit (outputs) configs;
};

__inputs__ = super.pops.loadInputs.outputs;

dotfiles = inputs.self.outPath + "/dotfiles";
Expand Down
13 changes: 9 additions & 4 deletions lib/exporter/pops.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ in
load.src = inputs.self.outPath + "/nixos/darwinModules";
};

configs = flops.haumea.pops.default.setInit {
src = inputs.self.outPath + "/units/configs";
inputs = baseInputs;
};

srvos = flops.haumea.pops.default.setInit {
src = self.loadInputs.outputs.srvos + "/nixos";
type = "nixosProfiles";
Expand All @@ -62,24 +67,24 @@ in
};
flake-parts = {
loadModules = self.loadNixOSModules.addLoadExtender {
load.src = inputs.self.outPath + "/evalModules/flake-parts/modules";
load.src = inputs.self.outPath + "/units/flake-parts/modules";
};
loadProfiles = self.loadNixOSProfiles.addLoadExtender {
load = {
src = inputs.self.outPath + "/evalModules/flake-parts/profiles";
src = inputs.self.outPath + "/units/flake-parts/profiles";
};
};
};
devshell = rec {
loadModules = self.loadNixOSModules.addLoadExtender {
load = {
src = inputs.self.outPath + "/evalModules/devshell/modules";
src = inputs.self.outPath + "/units/devshell/modules";
type = "nixosModules";
};
};
loadProfiles = self.loadNixOSProfiles.addLoadExtender {
load = {
src = inputs.self.outPath + "/evalModules/devshell/profiles";
src = inputs.self.outPath + "/units/devshell/profiles";
type = "nixosProfiles";
};
};
Expand Down
2 changes: 1 addition & 1 deletion lib/makes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let
l = nixpkgs.lib // builtins;
inherit
(root.errors.requiredInputs [
(root.errors.requiredInputs inputs [
"nixpkgs"
"makes"
])
Expand Down
2 changes: 1 addition & 1 deletion lib/mkHome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}:
userSet: shell: suites:
let
inherit (root.errors.requiredInputs [ "home-manager" ]) home-manager;
inherit (root.errors.requiredInputs inputs [ "home-manager" ]) home-manager;
user = lib.head (lib.attrNames userSet);
pathsToLinkShell = lib.elem shell [
"fish"
Expand Down
2 changes: 1 addition & 1 deletion lib/mkMicrovm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}:
let
inherit
(root.errors.requiredInputs [
(root.errors.requiredInputs inputs [
"nixpkgs"
"microvm"
])
Expand Down
48 changes: 48 additions & 0 deletions units/configs/cog.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{ inputs }:
{
default = {
output = "cog.toml";
commands = [ { package = inputs.nixpkgs.cocogitto; } ];
data = {
tag_prefix = "v";
branch_whitelist = [
"main"
"release/**"
];
ignore_merge_commits = true;
pre_bump_hooks = [
"echo {{version}} > ./VERSION"
''
branch="$(echo "release/{{version}}" | sed 's/\.[^.]*$//')"
if [ `git rev-parse --verify $branch 2>/dev/null` ]
then
git switch -m "$branch" || exit 1
git merge main
else
git switch -c "$branch" || exit 1
fi
''
];
post_bump_hooks = [
''
branch="$(echo "release/{{version}}" | sed 's/\.[^.]*$//')"
git push --set-upstream origin "$branch"
git push origin v{{version}}
git switch main
git merge "$branch" --no-commit --no-ff
echo {{version+minor-dev}} > ./VERSION
git add VERSION
git commit -m "chore: sync with release"
git push origin main
''
"cog -q changelog --at v{{version}}"
];
changelog = {
path = "CHANGELOG.md";
template = "remote";
remote = "github.com";
};
};
};
}
24 changes: 24 additions & 0 deletions units/configs/conform.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
default.data = {
commit = {
header = {
length = 89;
};
conventional = {
types = [
"build"
"chore"
"ci"
"docs"
"feat"
"fix"
"perf"
"refactor"
"style"
"test"
];
scopes = [ ];
};
};
};
}
33 changes: 33 additions & 0 deletions units/configs/editorconfig.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
default.data = {
root = true;
"*" = {
end_of_line = "lf";
insert_final_newline = true;
trim_trailing_whitespace = true;
charset = "utf-8";
indent_style = "space";
indent_size = 2;
};

"*.{diff,patch}" = {
end_of_line = "unset";
insert_final_newline = "unset";
trim_trailing_whitespace = "unset";
indent_size = "unset";
};

"*.md" = {
max_line_length = "off";
trim_trailing_whitespace = false;
};
"{LICENSES/**,LICENSE}" = {
end_of_line = "unset";
insert_final_newline = "unset";
trim_trailing_whitespace = "unset";
charset = "unset";
indent_style = "unset";
indent_size = "unset";
};
};
}
126 changes: 126 additions & 0 deletions units/configs/githubsettings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
let
colors = {
black = "#000000";
blue = "#1565C0";
lightBlue = "#64B5F6";
green = "#4CAF50";
grey = "#A6A6A6";
lightGreen = "#81C784";
gold = "#FDD835";
orange = "#FB8C00";
purple = "#AB47BC";
red = "#F44336";
yellow = "#FFEE58";
};
labels = {
statuses = {
abandoned = {
name = ":running: Status: Abdandoned";
description = "This issue has been abdandoned";
color = colors.black;
};
accepted = {
name = ":ok: Status: Accepted";
description = "This issue has been accepted";
color = colors.green;
};
blocked = {
name = ":x: Status: Blocked";
description = "This issue is in a blocking state";
color = colors.red;
};
inProgress = {
name = ":construction: Status: In Progress";
description = "This issue is actively being worked on";
color = colors.grey;
};
onHold = {
name = ":golf: Status: On Hold";
description = "This issue is not currently being worked on";
color = colors.red;
};
reviewNeeded = {
name = ":eyes: Status: Review Needed";
description = "This issue is pending a review";
color = colors.gold;
};
};
types = {
bug = {
name = ":bug: Type: Bug";
description = "This issue targets a bug";
color = colors.red;
};
story = {
name = ":scroll: Type: Story";
description = "This issue targets a new feature through a story";
color = colors.lightBlue;
};
maintenance = {
name = ":wrench: Type: Maintenance";
description = "This issue targets general maintenance";
color = colors.orange;
};
question = {
name = ":grey_question: Type: Question";
description = "This issue contains a question";
color = colors.purple;
};
security = {
name = ":cop: Type: Security";
description = "This issue targets a security vulnerability";
color = colors.red;
};
};
priorities = {
critical = {
name = ":boom: Priority: Critical";
description = "This issue is prioritized as critical";
color = colors.red;
};
high = {
name = ":fire: Priority: High";
description = "This issue is prioritized as high";
color = colors.orange;
};
medium = {
name = ":star2: Priority: Medium";
description = "This issue is prioritized as medium";
color = colors.yellow;
};
low = {
name = ":low_brightness: Priority: Low";
description = "This issue is prioritized as low";
color = colors.green;
};
};
effort = {
"1" = {
name = ":muscle: Effort: 1";
description = "This issue is of low complexity or very well understood";
color = colors.green;
};
"2" = {
name = ":muscle: Effort: 3";
description = "This issue is of medium complexity or only partly well understood";
color = colors.yellow;
};
"5" = {
name = ":muscle: Effort: 5";
description = "This issue is of high complexity or just not yet well understood";
color = colors.red;
};
};
};

l = builtins;
in
{
default.data.labels =
[ ]
++ (l.attrValues labels.statuses)
++ (l.attrValues labels.types)
++ (l.attrValues labels.priorities)
++ (l.attrValues labels.effort)
;
}
Loading

0 comments on commit 16510ea

Please sign in to comment.