add hm modules: riff

This commit is contained in:
Vivian 2022-12-26 13:02:48 +01:00
parent 3c0f89c66a
commit 4b90002e45
6 changed files with 79 additions and 45 deletions

View file

@ -454,11 +454,11 @@
"xdph": "xdph"
},
"locked": {
"lastModified": 1671841202,
"narHash": "sha256-w6vfVa6gj48YWjK+GUezq5U3UkvvGo/DEzdhAmr9Mhw=",
"lastModified": 1671982931,
"narHash": "sha256-cRInW7YYjw9xbjDTYOQD9PGo04aPAJWWu78PQ1HPkiQ=",
"owner": "hyprwm",
"repo": "Hyprland",
"rev": "d87d2dac0b1385a4ab944df293bc48877564106c",
"rev": "cd08fa22fd1ddbb8604e42d01043617a8eb10520",
"type": "github"
},
"original": {
@ -581,11 +581,11 @@
"utils": "utils_4"
},
"locked": {
"lastModified": 1671843840,
"narHash": "sha256-oYVOnPL+rpnDFKiNeEtSDiH1H2sMqpoJmCmtfcs8lT4=",
"lastModified": 1672017029,
"narHash": "sha256-VGztJsDy094qcoaP5gxY0kqpcKGa7olw5v5W1yWqHoc=",
"owner": "jyooru",
"repo": "nix-minecraft-servers",
"rev": "5a5f7a399e40c0e258aa0fd00529613b5ae2b7e7",
"rev": "8ded123b238808a95e8f3e8588d1dcfb96bdfa65",
"type": "github"
},
"original": {
@ -800,11 +800,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1671936867,
"narHash": "sha256-tOok3/MJWoRUEoPU5Ma/cTCeuw8ACx3Ozu1MlFcdvc8=",
"lastModified": 1671997655,
"narHash": "sha256-8zUwvnJrBwiFIdw9VgARj1PIQsto5Spn9J5v34b0O7A=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "18ee49839ea8817218c3bfe3a62e06f47a10fdd5",
"rev": "aac1f0b25e6b04afad8e05dec5828f5c02398bd1",
"type": "github"
},
"original": {
@ -886,11 +886,11 @@
},
"nur": {
"locked": {
"lastModified": 1671975941,
"narHash": "sha256-n5fEPkVVarOnmO70xxuMFlMwYiNQGEaFm/k1ebx/vMo=",
"lastModified": 1672047887,
"narHash": "sha256-+Ckjrzz+mXVRB2fm12QEpa8Cz/9hm/48emkzyPxh97E=",
"owner": "nix-community",
"repo": "NUR",
"rev": "ce94b3d5d00080485f7a6dba0243a21d10c69273",
"rev": "0457d302f72e13b29dcf914f19b9616cbec5e44e",
"type": "github"
},
"original": {

View file

@ -1,13 +1,12 @@
{ inputs, lib, config, ... }: {
# This file deals with everything requiring `inputs`, the rest being delagated to `common.nix`
# this is because we can't import inputs from all contexts as that can lead to infinite recursion.
imports = [
./common.nix
inputs.vault-secrets.nixosModules.vault-secrets
];
imports = [ ./common.nix inputs.vault-secrets.nixosModules.vault-secrets ];
nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
nix.registry.nixpkgs.flake = inputs.nixpkgs;
nix.registry.nixpkgs.flake = inputs.nixpkgs;
home-manager.sharedModules = [ ./hm-modules ];
vault-secrets = let
inherit (config.networking) domain hostName;

View file

@ -0,0 +1,5 @@
{ ... }: {
imports = [
./riff.nix
];
}

View file

@ -0,0 +1,28 @@
{ config, pkgs, lib, inputs, ... }:
with lib;
let cfg = config.programs.riff;
in {
options.programs.riff = {
enable = mkEnableOption "riff";
direnv = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable direnv support
'';
};
};
config = mkIf cfg.enable {
home.packages = [ inputs.riff.packages.${pkgs.system}.riff ];
xdg.configFile."direnv/lib/riff.sh" = mkIf cfg.direnv {
executable = true;
text = ''
use_riff() {
watch_file Cargo.toml watch_file Cargo.lock
eval "$(riff --offline print-dev-env)"
}
'';
};
};
}

View file

@ -21,7 +21,6 @@ in {
gcc
gimp
inputs.comma.packages.${pkgs.system}.default
inputs.riff.packages.${pkgs.system}.riff
inputs.webcord.packages.${pkgs.system}.default
jetbrains.clion
jetbrains.idea-ultimate
@ -36,6 +35,11 @@ in {
yt-dlp
];
programs.riff = {
enable = true;
direnv = true;
};
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = {
"text/html" = "firefox.desktop";

View file

@ -3,32 +3,31 @@ let
inherit (builtins) filter attrValues concatLists;
# Helper function to resolve what should be imported depending on the type of config (lxc, vm, bare metal)
resolve_imports =
let
# lookup table
import_cases = {
"lxc" = [
"${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix"
./common/generic-lxc.nix
];
"vm" = [
./common/generic-vm.nix
];
"local" = [
hyprland.nixosModules.default
];
};
in
{ hostname, realm, profile ? hostname, type ? "lxc", ... }: [
home-manager.nixosModules.home-manager
mailserver.nixosModules.mailserver
./common
"${./.}/hosts/${realm}/${profile}/configuration.nix"
] ++ import_cases.${type};
in
{
resolve_imports = let
# lookup table
import_cases = {
"lxc" = [
"${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix"
./common/generic-lxc.nix
];
"vm" = [ ./common/generic-vm.nix ];
"local" = [ hyprland.nixosModules.default ];
};
in { hostname, realm, profile ? hostname, type ? "lxc", ... }:
[
home-manager.nixosModules.home-manager
mailserver.nixosModules.mailserver
./common
"${./.}/hosts/${realm}/${profile}/configuration.nix"
] ++ import_cases.${type};
in {
# Add to whatever realm a host belong to its list of tags
add_realm_to_tags = realm: map ({ tags ? [ ], ... }@host: host // { tags = [ realm ] ++ tags; inherit realm; });
add_realm_to_tags = realm:
map ({ tags ? [ ], ... }@host:
host // {
tags = [ realm ] ++ tags;
inherit realm;
});
# Flatten all hosts to a single list
flatten_hosts = hosts: concatLists (attrValues hosts);
# Filter out all hosts which aren't nixos
@ -39,8 +38,7 @@ in
let
# this makes local apply work a bit nicer
name = if realm == "thalassa" then hostname else "${hostname}.${realm}";
in
{
in {
"${name}" = {
imports = resolve_imports host;
networking = {