feat: simplify flake.nix

This commit is contained in:
Ryan Yin
2023-07-26 20:07:42 +08:00
parent eebbb9f5e6
commit 204cb03922
70 changed files with 1183 additions and 1165 deletions

View File

@@ -1,5 +1,4 @@
{ pkgs, ... }:
{
{pkgs, ...}: {
home.packages = with pkgs; [
# creative
# blender # 3d modeling

View File

@@ -1,5 +1,4 @@
{ pkgs, ... }:
{
{pkgs, ...}: {
imports = [
./creative.nix
./immutable-file.nix
@@ -10,7 +9,7 @@
home.packages = with pkgs; [
# GUI apps
insomnia # REST client
insomnia # REST client
wireshark # network analyzer
# e-book viewer(.epub/.mobi/...)

View File

@@ -1,26 +1,24 @@
{ config
, lib
, pkgs
, ...
{
config,
lib,
pkgs,
...
}:
##############################################################################################
#
# Provide a option `home.immutable-file`, it works like `home.file` but make the generated file immutable.
#
# Copy from https://github.com/iosmanthus/nixos-config/blob/349917b/modules/immutable-file.nix
#
# this module use the `chattr +i` to make the file immutable, `i` indicates `immutable`,
# this module use the `chattr +i` to make the file immutable, `i` indicates `immutable`,
# it's a i-node flags only works on Linux.
#
#
# TODO not used yet, need to test it.
#
#
##############################################################################################
with lib;
let
with lib; let
cfg = config.home.immutable-file;
immutableFileOpts = { ... }: {
immutableFileOpts = {...}: {
options = {
src = mkOption {
type = types.path;
@@ -44,21 +42,24 @@ let
sudo cp $2 $1
sudo chattr +i $1
'';
in
{
in {
options.home.immutable-file = mkOption {
type = with types; attrsOf (submodule immutableFileOpts);
default = { };
default = {};
};
config = mkIf (cfg != { }) {
home.activation = mapAttrs'
(name: { src, dst }:
config = mkIf (cfg != {}) {
home.activation =
mapAttrs'
(name: {
src,
dst,
}:
nameValuePair
"make-immutable-${name}"
(lib.hm.dag.entryAfter [ "writeBoundary" ] ''
${mkImmutableFile} ${dst} ${src}
''))
"make-immutable-${name}"
(lib.hm.dag.entryAfter ["writeBoundary"] ''
${mkImmutableFile} ${dst} ${src}
''))
cfg;
};
}
}

View File

@@ -1,6 +1,7 @@
{ pkgs
, config
, ...
{
pkgs,
config,
...
}:
# media - control and enjoy audio/video
{
@@ -23,8 +24,8 @@
programs = {
mpv = {
enable = true;
defaultProfiles = [ "gpu-hq" ];
scripts = [ pkgs.mpvScripts.mpris ];
defaultProfiles = ["gpu-hq"];
scripts = [pkgs.mpvScripts.mpris];
};
};

View File

@@ -1,6 +1,4 @@
{ pkgs
, ...
}: {
{pkgs, ...}: {
programs.ssh = {
enable = true;
@@ -35,7 +33,7 @@
Host gtr5
HostName 192.168.5.172
Port 22
Host um560
HostName 192.168.5.173
Port 22

View File

@@ -1,9 +1,12 @@
# XDG stands for "Cross-Desktop Group", with X used to mean "cross".
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
# XDG stands for "Cross-Desktop Group", with X used to mean "cross".
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
# https://www.freedesktop.org/wiki/Specifications/
{ config, pkgs, ... }:
{
config,
pkgs,
...
}: {
home.packages = with pkgs; [
xdg-utils # provides cli tools such as `xdg-mime` `xdg-open`
xdg-user-dirs
@@ -15,68 +18,64 @@
# manage $XDG_CONFIG_HOME/mimeapps.list
# xdg search all desktop entries from $XDG_DATA_DIRS, check it by command:
# echo $XDG_DATA_DIRS
# echo $XDG_DATA_DIRS
# the system-level desktop entries can be list by command:
# ls -l /run/current-system/sw/share/applications/
# the user-level desktop entries can be list by command(user ryan):
# ls /etc/profiles/per-user/ryan/share/applications/
mimeApps = {
enable = true;
defaultApplications =
let
browser = [ "firefox.desktop" ];
in
{
"application/json" = browser;
"application/pdf" = browser; # TODO: pdf viewer
defaultApplications = let
browser = ["firefox.desktop"];
in {
"application/json" = browser;
"application/pdf" = browser; # TODO: pdf viewer
"text/html" = browser;
"text/xml" = browser;
"application/xml" = browser;
"application/xhtml+xml" = browser;
"application/xhtml_xml" = browser;
"application/rdf+xml" = browser;
"application/rss+xml" = browser;
"application/x-extension-htm" = browser;
"application/x-extension-html" = browser;
"application/x-extension-shtml" = browser;
"application/x-extension-xht" = browser;
"application/x-extension-xhtml" = browser;
"text/html" = browser;
"text/xml" = browser;
"application/xml" = browser;
"application/xhtml+xml" = browser;
"application/xhtml_xml" = browser;
"application/rdf+xml" = browser;
"application/rss+xml" = browser;
"application/x-extension-htm" = browser;
"application/x-extension-html" = browser;
"application/x-extension-shtml" = browser;
"application/x-extension-xht" = browser;
"application/x-extension-xhtml" = browser;
"x-scheme-handler/about" = browser;
"x-scheme-handler/ftp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/unknown" = browser;
"x-scheme-handler/about" = browser;
"x-scheme-handler/ftp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/unknown" = browser;
"x-scheme-handler/discord" = [ "discord.desktop" ];
"x-scheme-handler/tg" = [ "telegramdesktop.desktop" ];
"x-scheme-handler/discord" = ["discord.desktop"];
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
"audio/*" = [ "mpv.desktop" ];
"video/*" = [ "mpv.dekstop" ];
"image/*" = [ "imv.desktop" ];
};
"audio/*" = ["mpv.desktop"];
"video/*" = ["mpv.dekstop"];
"image/*" = ["imv.desktop"];
};
associations.removed =
let
browser = [ "google-chrome.desktop" ];
in
{
"text/html" = browser;
"text/xml" = browser;
"application/xml" = browser;
"application/xhtml+xml" = browser;
"application/xhtml_xml" = browser;
"application/rdf+xml" = browser;
"application/rss+xml" = browser;
"image/gif" = browser;
"image/jpeg" = browser;
"image/png" = browser;
"image/webp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"application/pdf" = browser;
};
associations.removed = let
browser = ["google-chrome.desktop"];
in {
"text/html" = browser;
"text/xml" = browser;
"application/xml" = browser;
"application/xhtml+xml" = browser;
"application/xhtml_xml" = browser;
"application/rdf+xml" = browser;
"application/rss+xml" = browser;
"image/gif" = browser;
"image/jpeg" = browser;
"image/png" = browser;
"image/webp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"application/pdf" = browser;
};
};
userDirs = {