mirror of
https://github.com/sstent/vmimages.git
synced 2025-12-06 06:01:51 +00:00
sync
This commit is contained in:
34
flake.lock
generated
34
flake.lock
generated
@@ -61,21 +61,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1644229661,
|
|
||||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -261,7 +246,6 @@
|
|||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||||
"sops-nix": "sops-nix",
|
"sops-nix": "sops-nix",
|
||||||
"utils": "utils_2",
|
|
||||||
"vscode-server": "vscode-server"
|
"vscode-server": "vscode-server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -299,24 +283,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"utils_2": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_3"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1657226504,
|
|
||||||
"narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=",
|
|
||||||
"owner": "gytis-ivaskevicius",
|
|
||||||
"repo": "flake-utils-plus",
|
|
||||||
"rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "gytis-ivaskevicius",
|
|
||||||
"repo": "flake-utils-plus",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vscode-server": {
|
"vscode-server": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs_3"
|
||||||
|
|||||||
17
flake.nix
17
flake.nix
@@ -28,7 +28,6 @@
|
|||||||
vscode-server.url = "github:msteen/nixos-vscode-server";
|
vscode-server.url = "github:msteen/nixos-vscode-server";
|
||||||
|
|
||||||
# homeage = {url = "github:jordanisaacs/homeage"; inputs.nixpkgs.follows = "nixpkgs";};
|
# homeage = {url = "github:jordanisaacs/homeage"; inputs.nixpkgs.follows = "nixpkgs";};
|
||||||
# Nix Library Functions
|
|
||||||
library = {
|
library = {
|
||||||
type = "github";
|
type = "github";
|
||||||
owner = "nix-community";
|
owner = "nix-community";
|
||||||
@@ -36,27 +35,29 @@
|
|||||||
ref = "master";
|
ref = "master";
|
||||||
rev = "af5239f892ae6e1c8bb560b11ed874cebbd10696";
|
rev = "af5239f892ae6e1c8bb560b11ed874cebbd10696";
|
||||||
};
|
};
|
||||||
# Source Filter Functions
|
|
||||||
filter.url = "github:numtide/nix-filter";
|
filter.url = "github:numtide/nix-filter";
|
||||||
ignore = {
|
ignore = {
|
||||||
url = "github:hercules-ci/gitignore.nix";
|
url = "github:hercules-ci/gitignore.nix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Flake Utility Functions
|
|
||||||
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, home-manager,library, ignore, filter,... }@inputs:
|
outputs = { self, nixpkgs, home-manager, ignore, filter, library,... }@inputs:
|
||||||
let
|
let
|
||||||
inherit (self) outputs;
|
inherit (self) outputs;
|
||||||
|
inherit (lib.my) mapModules mapModulesRec mapHosts;
|
||||||
|
|
||||||
forEachSystem = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ];
|
forEachSystem = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ];
|
||||||
platforms = ["x86_64-linux"];
|
platforms = ["x86_64-linux"];
|
||||||
|
|
||||||
forEachPkgs = f: forEachSystem (sys: f nixpkgs.legacyPackages.${sys});
|
forEachPkgs = f: forEachSystem (sys: f nixpkgs.legacyPackages.${sys});
|
||||||
|
|
||||||
|
lib = nixpkgs.lib.extend
|
||||||
|
(self: super: { my = import ./lib { inherit nixpkgs inputs; lib = self; }; });
|
||||||
|
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; });
|
packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; });
|
||||||
@@ -65,7 +66,7 @@
|
|||||||
nixosModules = import ./modules/nixos;
|
nixosModules = import ./modules/nixos;
|
||||||
homeManagerModules = import ./modules/home-manager;
|
homeManagerModules = import ./modules/home-manager;
|
||||||
|
|
||||||
util = import ./lib/map.nix;
|
lib = lib.my;
|
||||||
|
|
||||||
# NixOS configuration entrypoint
|
# NixOS configuration entrypoint
|
||||||
# Available through 'nixos-rebuild --flake .#your-hostname'
|
# Available through 'nixos-rebuild --flake .#your-hostname'
|
||||||
@@ -91,7 +92,7 @@
|
|||||||
# FIXME replace with your username@hostname
|
# FIXME replace with your username@hostname
|
||||||
"sstent@Go3" = home-manager.lib.homeManagerConfiguration {
|
"sstent@Go3" = home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
|
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
|
||||||
extraSpecialArgs = { inherit inputs outputs; hostName = "Go3"; };
|
extraSpecialArgs = { inherit inputs outputs lib; hostName = "Go3"; };
|
||||||
modules = [
|
modules = [
|
||||||
# > Our main home-manager configuration file <
|
# > Our main home-manager configuration file <
|
||||||
./home-manager/users/sstent
|
./home-manager/users/sstent
|
||||||
|
|||||||
@@ -1,53 +1,11 @@
|
|||||||
{ config, pkgs, inputs, lib, hostName, util, ... }:
|
{ config, pkgs, lib, inputs, hostName, outputs, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
|
with lib.my;
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit
|
|
||||||
(builtins)
|
|
||||||
# attrNames
|
|
||||||
# attrValues
|
|
||||||
# foldl'
|
|
||||||
# isPath
|
|
||||||
# pathExists
|
|
||||||
readDir
|
|
||||||
# toString
|
|
||||||
;
|
|
||||||
|
|
||||||
inherit
|
|
||||||
(lib)
|
|
||||||
# flatten
|
|
||||||
filterAttrs
|
|
||||||
# forEach
|
|
||||||
# getAttrFromPath
|
|
||||||
# hasPrefix
|
|
||||||
# hasSuffix
|
|
||||||
# id
|
|
||||||
# mapAttrs'
|
|
||||||
# mapAttrsToList
|
|
||||||
# mkIf
|
|
||||||
# nameValuePair
|
|
||||||
# removeSuffix
|
|
||||||
;
|
|
||||||
cfg = config.custom.keybase;
|
cfg = config.custom.keybase;
|
||||||
username = config.home.username;
|
username = config.home.username;
|
||||||
secretstore = config._secretstore;
|
secretstore = config._secretstore;
|
||||||
# map = import "${inputs.self}/lib/map.nix";
|
|
||||||
|
|
||||||
# 'sops' Encrypted Secrets
|
|
||||||
hm_secrets = dir: out_dir:
|
|
||||||
filter (name: type: type != null && !(hasPrefix "_" name)) (name: type:
|
|
||||||
if type == "regular"
|
|
||||||
then
|
|
||||||
nameValuePair name {
|
|
||||||
sopsFile = dir + "/${name}";
|
|
||||||
format = "binary";
|
|
||||||
path = out_dir + "/${name}";
|
|
||||||
|
|
||||||
}
|
|
||||||
else nameValuePair "" null) (readDir dir);
|
|
||||||
|
|
||||||
filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
|
|
||||||
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
# imports = [
|
# imports = [
|
||||||
@@ -70,7 +28,7 @@ in {
|
|||||||
systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ];
|
systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ];
|
||||||
|
|
||||||
sops = {
|
sops = {
|
||||||
secrets = hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/";
|
secrets = map.hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
26
lib/attrs.nix
Normal file
26
lib/attrs.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
with builtins;
|
||||||
|
with lib;
|
||||||
|
rec {
|
||||||
|
# attrsToList
|
||||||
|
attrsToList = attrs:
|
||||||
|
mapAttrsToList (name: value: { inherit name value; }) attrs;
|
||||||
|
|
||||||
|
# mapFilterAttrs ::
|
||||||
|
# (name -> value -> bool)
|
||||||
|
# (name -> value -> { name = any; value = any; })
|
||||||
|
# attrs
|
||||||
|
mapFilterAttrs = pred: f: attrs: filterAttrs pred (mapAttrs' f attrs);
|
||||||
|
|
||||||
|
# Generate an attribute set by mapping a function over a list of values.
|
||||||
|
genAttrs' = values: f: listToAttrs (map f values);
|
||||||
|
|
||||||
|
# anyAttrs :: (name -> value -> bool) attrs
|
||||||
|
anyAttrs = pred: attrs:
|
||||||
|
any (attr: pred attr.name attr.value) (attrsToList attrs);
|
||||||
|
|
||||||
|
# countAttrs :: (name -> value -> bool) attrs
|
||||||
|
countAttrs = pred: attrs:
|
||||||
|
count (attr: pred attr.name attr.value) (attrsToList attrs);
|
||||||
|
}
|
||||||
@@ -1,11 +1,33 @@
|
|||||||
{
|
# {lib}:
|
||||||
self,
|
# lib.makeExtensible (self:
|
||||||
platforms,
|
# let
|
||||||
lib,
|
# callLibs = file: import file { lib = self; };
|
||||||
} @ args:
|
# in
|
||||||
with {inherit (lib) makeExtensible attrValues foldr;};
|
# rec {
|
||||||
(makeExtensible (final:
|
# ## Define your own library functions here!
|
||||||
with final;
|
# #id = x: x;
|
||||||
(import ./map.nix args).modules ./. (file: import file args)))
|
# ## Or in files, containing functions that take {lib}
|
||||||
.extend
|
# map = callLibs ./map.nix;
|
||||||
(final: prev: foldr (x: y: x // y) {} (attrValues prev))
|
# ## 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))
|
||||||
30
lib/generators.nix
Normal file
30
lib/generators.nix
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{ 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}";
|
||||||
|
}
|
||||||
53
lib/modules.nix
Normal file
53
lib/modules.nix
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
{ self, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (builtins) attrValues readDir pathExists concatLists;
|
||||||
|
inherit (lib) id mapAttrsToList filterAttrs hasPrefix hasSuffix nameValuePair removeSuffix;
|
||||||
|
inherit (self.attrs) mapFilterAttrs;
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
25
lib/nixos.nix
Normal file
25
lib/nixos.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{ inputs, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
with lib.my;
|
||||||
|
let sys = "x86_64-linux";
|
||||||
|
in {
|
||||||
|
mkHost = path: attrs @ { system ? sys, ... }:
|
||||||
|
nixosSystem {
|
||||||
|
inherit 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
|
||||||
|
(import path)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
mapHosts = dir: attrs @ { system ? system, ... }:
|
||||||
|
mapModules dir
|
||||||
|
(hostPath: mkHost hostPath attrs);
|
||||||
|
}
|
||||||
18
lib/options.nix
Normal file
18
lib/options.nix
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
mkOpt = type: default:
|
||||||
|
mkOption { inherit type default; };
|
||||||
|
|
||||||
|
mkOpt' = type: default: description:
|
||||||
|
mkOption { inherit type default description; };
|
||||||
|
|
||||||
|
mkBoolOpt = default: mkOption {
|
||||||
|
inherit default;
|
||||||
|
type = types.bool;
|
||||||
|
example = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user