mirror of
https://github.com/sstent/vmimages.git
synced 2026-02-07 04:51:42 +00:00
new flake
This commit is contained in:
19
modules/nixos/default.nix
Normal file
19
modules/nixos/default.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{lib, ...}:
|
||||
with lib; let
|
||||
# Recursively constructs an attrset of a given folder, recursing on directories, value of attrs is the filetype
|
||||
getDir = dir:
|
||||
mapAttrs (
|
||||
file: type:
|
||||
if type == "directory"
|
||||
then getDir "${dir}/${file}"
|
||||
else type
|
||||
) (builtins.readDir dir);
|
||||
|
||||
# Collects all files of a directory as a list of strings of paths
|
||||
files = dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir));
|
||||
|
||||
# Filters out directories that don't end with .nix or are this file, also makes the strings absolute
|
||||
validFiles = dir: map (file: ./. + "/${file}") (filter (file: hasSuffix ".nix" file && file != "default.nix" && ! lib.hasPrefix "x/taffybar/" file) (files dir));
|
||||
in {
|
||||
imports = validFiles ./.;
|
||||
}
|
||||
@@ -5,13 +5,13 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
secretstore = config._secretstore;
|
||||
# secretstore = config._secretstore;
|
||||
host = config.networking.hostName;
|
||||
|
||||
cfg = config.custom.mullvad;
|
||||
|
||||
secret =
|
||||
if builtins.pathExists "${secretstore}/hosts/${host}/mullvad/device.json"
|
||||
if builtins.pathExists "../../..//hosts/${host}/mullvad/device.json"
|
||||
then ./secrets.nix
|
||||
else {};
|
||||
in {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
secretstore = config._secretstore;
|
||||
# secretstore = config._secretstore;
|
||||
host = config.networking.hostName;
|
||||
secretpath = "${secretstore}/hosts/${host}/mullvad/device.json";
|
||||
# secretpath = "../../../secrets/hosts/${host}/mullvad/device.json";
|
||||
in {
|
||||
sops.secrets.device_json = {
|
||||
sopsFile = "${secretstore}/hosts/${host}/mullvad/device.json";
|
||||
device_json.format = "binary";
|
||||
sopsFile = ../../../secrets/hosts/${host}/mullvad/device.json;
|
||||
format = "binary";
|
||||
};
|
||||
|
||||
environment.etc."mullvad-vpn/device.conf".source = config.sops.secrets.device_json.path;
|
||||
|
||||
Reference in New Issue
Block a user