mirror of
https://github.com/sstent/vmimages.git
synced 2026-01-25 06:31:35 +00:00
addin ssh key
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{lib, ...}:
|
||||
with builtins;
|
||||
with lib;
|
||||
rec {
|
||||
with lib; rec {
|
||||
# attrsToList
|
||||
attrsToList = attrs:
|
||||
mapAttrsToList (name: value: { inherit name value; }) attrs;
|
||||
mapAttrsToList (name: value: {inherit name value;}) attrs;
|
||||
|
||||
# mapFilterAttrs ::
|
||||
# (name -> value -> bool)
|
||||
|
||||
@@ -1,33 +1,37 @@
|
||||
# {lib}:
|
||||
# lib.makeExtensible (self:
|
||||
# let
|
||||
# callLibs = file: import file { lib = self; };
|
||||
# in
|
||||
# rec {
|
||||
# ## Define your own library functions here!
|
||||
# #id = x: x;
|
||||
# ## Or in files, containing functions that take {lib}
|
||||
# map = callLibs ./map.nix;
|
||||
# ## In configs, they can be used under "lib.our"
|
||||
# })
|
||||
|
||||
|
||||
|
||||
{ inputs, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) makeExtensible attrValues foldr;
|
||||
inherit (modules) mapModules;
|
||||
|
||||
modules = import ./modules.nix {
|
||||
inherit lib;
|
||||
self.attrs = import ./attrs.nix { inherit lib; self = {}; };
|
||||
};
|
||||
|
||||
mylib = makeExtensible (self:
|
||||
with self; mapModules ./.
|
||||
(file: import file { inherit self lib pkgs inputs; }));
|
||||
in
|
||||
mylib.extend
|
||||
(self: super:
|
||||
foldr (a: b: a // b) {} (attrValues super))
|
||||
# {lib}:
|
||||
# lib.makeExtensible (self:
|
||||
# let
|
||||
# callLibs = file: import file { lib = self; };
|
||||
# in
|
||||
# rec {
|
||||
# ## Define your own library functions here!
|
||||
# #id = x: x;
|
||||
# ## Or in files, containing functions that take {lib}
|
||||
# map = callLibs ./map.nix;
|
||||
# ## In configs, they can be used under "lib.our"
|
||||
# })
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) makeExtensible attrValues foldr;
|
||||
inherit (modules) mapModules;
|
||||
|
||||
modules = import ./modules.nix {
|
||||
inherit lib;
|
||||
self.attrs = import ./attrs.nix {
|
||||
inherit lib;
|
||||
self = {};
|
||||
};
|
||||
};
|
||||
|
||||
mylib = makeExtensible (self:
|
||||
with self;
|
||||
mapModules ./.
|
||||
(file: import file {inherit self lib pkgs inputs;}));
|
||||
in
|
||||
mylib.extend
|
||||
(self: super:
|
||||
foldr (a: b: a // b) {} (attrValues super))
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
with builtins;
|
||||
with lib;
|
||||
{
|
||||
toCSSFile = file:
|
||||
let fileName = removeSuffix ".scss" (baseNameOf file);
|
||||
compiledStyles =
|
||||
pkgs.runCommand "compileScssFile"
|
||||
{ buildInputs = [ pkgs.sass ]; } ''
|
||||
mkdir "$out"
|
||||
scss --sourcemap=none \
|
||||
--no-cache \
|
||||
--style compressed \
|
||||
--default-encoding utf-8 \
|
||||
"${file}" \
|
||||
>>"$out/${fileName}.css"
|
||||
'';
|
||||
in "${compiledStyles}/${fileName}.css";
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with builtins;
|
||||
with lib; {
|
||||
toCSSFile = file: let
|
||||
fileName = removeSuffix ".scss" (baseNameOf file);
|
||||
compiledStyles =
|
||||
pkgs.runCommand "compileScssFile"
|
||||
{buildInputs = [pkgs.sass];} ''
|
||||
mkdir "$out"
|
||||
scss --sourcemap=none \
|
||||
--no-cache \
|
||||
--style compressed \
|
||||
--default-encoding utf-8 \
|
||||
"${file}" \
|
||||
>>"$out/${fileName}.css"
|
||||
'';
|
||||
in "${compiledStyles}/${fileName}.css";
|
||||
|
||||
toFilteredImage = imageFile: options:
|
||||
let result = "result.png";
|
||||
filteredImage =
|
||||
pkgs.runCommand "filterWallpaper"
|
||||
{ buildInputs = [ pkgs.imagemagick ]; } ''
|
||||
mkdir "$out"
|
||||
convert ${options} ${imageFile} $out/${result}
|
||||
'';
|
||||
in "${filteredImage}/${result}";
|
||||
toFilteredImage = imageFile: options: let
|
||||
result = "result.png";
|
||||
filteredImage =
|
||||
pkgs.runCommand "filterWallpaper"
|
||||
{buildInputs = [pkgs.imagemagick];} ''
|
||||
mkdir "$out"
|
||||
convert ${options} ${imageFile} $out/${result}
|
||||
'';
|
||||
in "${filteredImage}/${result}";
|
||||
}
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
{lib, ...}: let
|
||||
inherit
|
||||
(builtins)
|
||||
readDir
|
||||
;
|
||||
|
||||
inherit
|
||||
(lib)
|
||||
filterAttrs
|
||||
hasPrefix
|
||||
hasSuffix
|
||||
mapAttrs'
|
||||
nameValuePair
|
||||
|
||||
;
|
||||
in rec {
|
||||
filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
|
||||
|
||||
# 'sops' Encrypted Secrets
|
||||
hm_secrets = dir: out_dir:
|
||||
filter (name: type: type != null && !(hasPrefix "_" name)) (name: type:
|
||||
# if type == "regular" && hasSuffix ".age" name
|
||||
if type == "regular"
|
||||
then
|
||||
nameValuePair name {
|
||||
sopsFile = dir + "/${name}";
|
||||
format = "binary";
|
||||
path = out_dir + "/${name}";
|
||||
|
||||
}
|
||||
else nameValuePair "" null) (readDir dir);
|
||||
}
|
||||
{lib, ...}: let
|
||||
inherit
|
||||
(builtins)
|
||||
readDir
|
||||
;
|
||||
|
||||
inherit
|
||||
(lib)
|
||||
filterAttrs
|
||||
hasPrefix
|
||||
hasSuffix
|
||||
mapAttrs'
|
||||
nameValuePair
|
||||
;
|
||||
in rec {
|
||||
filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
|
||||
|
||||
# 'sops' Encrypted Secrets
|
||||
hm_secrets = dir: out_dir:
|
||||
filter (name: type: type != null && !(hasPrefix "_" name)) (name: type:
|
||||
# if type == "regular" && hasSuffix ".age" name
|
||||
if type == "regular"
|
||||
then
|
||||
nameValuePair name {
|
||||
sopsFile = dir + "/${name}";
|
||||
format = "binary";
|
||||
path = out_dir + "/${name}";
|
||||
}
|
||||
else nameValuePair "" null) (readDir dir);
|
||||
}
|
||||
|
||||
@@ -1,53 +1,60 @@
|
||||
{ self, lib, ... }:
|
||||
|
||||
let
|
||||
{
|
||||
self,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrValues readDir pathExists concatLists;
|
||||
inherit (lib) id mapAttrsToList filterAttrs hasPrefix hasSuffix nameValuePair removeSuffix;
|
||||
inherit (self.attrs) mapFilterAttrs;
|
||||
in
|
||||
rec {
|
||||
in rec {
|
||||
mapModules = dir: fn:
|
||||
mapFilterAttrs
|
||||
(n: v:
|
||||
v != null &&
|
||||
!(hasPrefix "_" n))
|
||||
(n: v:
|
||||
let path = "${toString dir}/${n}"; in
|
||||
if v == "directory" && pathExists "${path}/default.nix"
|
||||
then nameValuePair n (fn path)
|
||||
else if v == "regular" &&
|
||||
n != "default.nix" &&
|
||||
hasSuffix ".nix" n
|
||||
then nameValuePair (removeSuffix ".nix" n) (fn path)
|
||||
else nameValuePair "" null)
|
||||
(readDir dir);
|
||||
(n: v:
|
||||
v
|
||||
!= null
|
||||
&& !(hasPrefix "_" n))
|
||||
(n: v: let
|
||||
path = "${toString dir}/${n}";
|
||||
in
|
||||
if v == "directory" && pathExists "${path}/default.nix"
|
||||
then nameValuePair n (fn path)
|
||||
else if
|
||||
v
|
||||
== "regular"
|
||||
&& n != "default.nix"
|
||||
&& hasSuffix ".nix" n
|
||||
then nameValuePair (removeSuffix ".nix" n) (fn path)
|
||||
else nameValuePair "" null)
|
||||
(readDir dir);
|
||||
|
||||
mapModules' = dir: fn:
|
||||
attrValues (mapModules dir fn);
|
||||
|
||||
mapModulesRec = dir: fn:
|
||||
mapFilterAttrs
|
||||
(n: v:
|
||||
v != null &&
|
||||
!(hasPrefix "_" n))
|
||||
(n: v:
|
||||
let path = "${toString dir}/${n}"; in
|
||||
if v == "directory"
|
||||
then nameValuePair n (mapModulesRec path fn)
|
||||
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
|
||||
then nameValuePair (removeSuffix ".nix" n) (fn path)
|
||||
else nameValuePair "" null)
|
||||
(readDir dir);
|
||||
(n: v:
|
||||
v
|
||||
!= null
|
||||
&& !(hasPrefix "_" n))
|
||||
(n: v: let
|
||||
path = "${toString dir}/${n}";
|
||||
in
|
||||
if v == "directory"
|
||||
then nameValuePair n (mapModulesRec path fn)
|
||||
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
|
||||
then nameValuePair (removeSuffix ".nix" n) (fn path)
|
||||
else nameValuePair "" null)
|
||||
(readDir dir);
|
||||
|
||||
mapModulesRec' = dir: fn:
|
||||
let
|
||||
dirs =
|
||||
mapAttrsToList
|
||||
(k: _: "${dir}/${k}")
|
||||
(filterAttrs
|
||||
(n: v: v == "directory" && !(hasPrefix "_" n))
|
||||
(readDir dir));
|
||||
files = attrValues (mapModules dir id);
|
||||
paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs);
|
||||
in map fn paths;
|
||||
mapModulesRec' = dir: fn: let
|
||||
dirs =
|
||||
mapAttrsToList
|
||||
(k: _: "${dir}/${k}")
|
||||
(filterAttrs
|
||||
(n: v: v == "directory" && !(hasPrefix "_" n))
|
||||
(readDir dir));
|
||||
files = attrValues (mapModules dir id);
|
||||
paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs);
|
||||
in
|
||||
map fn paths;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
{ inputs, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with lib.my;
|
||||
let sys = "x86_64-linux";
|
||||
with lib.my; let
|
||||
sys = "x86_64-linux";
|
||||
in {
|
||||
mkHost = path: attrs @ { system ? sys, ... }:
|
||||
mkHost = path: attrs @ {system ? sys, ...}:
|
||||
nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit lib inputs system; };
|
||||
specialArgs = {inherit lib inputs system;};
|
||||
modules = [
|
||||
{
|
||||
nixpkgs.pkgs = pkgs;
|
||||
networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path));
|
||||
}
|
||||
(filterAttrs (n: v: !elem n [ "system" ]) attrs)
|
||||
../. # /default.nix
|
||||
(filterAttrs (n: v: !elem n ["system"]) attrs)
|
||||
../. # /default.nix
|
||||
(import path)
|
||||
];
|
||||
};
|
||||
|
||||
mapHosts = dir: attrs @ { system ? system, ... }:
|
||||
mapHosts = dir: attrs @ {system ? system, ...}:
|
||||
mapModules dir
|
||||
(hostPath: mkHost hostPath attrs);
|
||||
(hostPath: mkHost hostPath attrs);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
{lib, ...}: let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
rec {
|
||||
mkOpt = type: default:
|
||||
mkOption { inherit type default; };
|
||||
in rec {
|
||||
mkOpt = type: default:
|
||||
mkOption {inherit type default;};
|
||||
|
||||
mkOpt' = type: default: description:
|
||||
mkOption { inherit type default description; };
|
||||
mkOption {inherit type default description;};
|
||||
|
||||
mkBoolOpt = default: mkOption {
|
||||
inherit default;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
};
|
||||
mkBoolOpt = default:
|
||||
mkOption {
|
||||
inherit default;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user