Skip to content

Commit

Permalink
feat: factorize nixos config and centralize unfree predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnossiom committed Jan 1, 2024
1 parent a2176f6 commit 1d7c63d
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 356 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);

packages = forAllSystems (system: import ./pkgs (import nixpkgs { inherit system; config.allowUnfree = true; }));
packages = forAllSystems (system: import ./pkgs (import nixpkgs { inherit system; config.allowUnfreePredicate = import ../lib/unfree nixpkgs.legacyPackages.${system}; }));
apps = forAllSystems (system: import ./apps (nixpkgs.legacyPackages.${system} // { inherit self; }));

overlays = import ./overlays (nixpkgs // { inherit self; });
Expand Down
311 changes: 152 additions & 159 deletions home-manager/profiles/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, lib
, config
, pkgs
# Provides the NixOS configuration if HM was loaded through the NixOS module
, osConfig ? null
, ...
}:
Expand All @@ -12,9 +13,6 @@ let
inherit (self.inputs) agenix nix-index-database nix-colors;
inherit (self.outputs) overlays;

# Says is the config has been loaded by the NixOS HM module or is it a standalone installation.
isNixosManaged = osConfig != null;

tomlFormat = pkgs.formats.toml { };
in
{
Expand All @@ -37,192 +35,187 @@ in
../modules/shell.nix
];

nixpkgs = {
overlays = [ overlays.all ];

config = {
allowUnfreePredicate = pkg: builtins.elem (getName pkg) [
"authy"
"discord"
"spotify"
"vscode"
"thorium-browser"
"unrar"
"geogebra"
];
config = {
nixpkgs = {
overlays = [ overlays.all ];
config.allowUnfreePredicate = import ../../lib/unfree.nix pkgs;
};
};

programs.home-manager.enable = !isNixosManaged;
programs.home-manager.enable = osConfig == null;

home = {
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
stateVersion = "23.05";
username = "milomoisson";
homeDirectory = "/home/milomoisson";
home = {
stateVersion =
if osConfig != null
then osConfig.system.stateVersion
else "23.11";

sessionVariables = {
XDG_DESKTOP_DIR = "$HOME";
username = "milomoisson";
homeDirectory = "/home/milomoisson";

# Respect XDG spec
BUN_INSTALL = "${config.xdg.dataHome}/bun";
CALCHISTFILE = "${config.xdg.cacheHome}/calc_history";
HISTFILE = "${config.xdg.dataHome}/bash_history";
RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
WAKATIME_HOME = "${config.xdg.configHome}/wakatime";
};
sessionVariables = {
XDG_DESKTOP_DIR = "$HOME";

# Respect XDG spec
file.".npmrc".text = ''
prefix=${config.xdg.dataHome}/npm
cache=${config.xdg.cacheHome}/npm
init-module=${config.xdg.configHome}/npm/config/npm-init.js
logs-dir=${config.xdg.stateHome}/npm/logs
'';

packages = with pkgs; [
# Unfree packages
authy
discord
spotify
thorium
geogebra6

# GUIs
cinnamon.nemo
transmission-gtk
gnome.gnome-disk-utility
greenlight
cura
blender
element-desktop

xdg-utils
rustup # TODO: not sure to keep rustup in path
spotify-tui

# CLI tools
bat
fd
delta
ripgrep
glow
fzf
btop
tealdeer
jq
calc

imv
mpv
wl-clipboard
wf-recorder
];
};
NIXOS_OZONE_WL = "1";

xdg.configFile."tealdeer/config.toml".source = tomlFormat.generate "tealdeer-config" {
updates.auto_update = true;
};
# Respect XDG spec
BUN_INSTALL = "${config.xdg.dataHome}/bun";
CALCHISTFILE = "${config.xdg.cacheHome}/calc_history";
HISTFILE = "${config.xdg.dataHome}/bash_history";
RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
WAKATIME_HOME = "${config.xdg.configHome}/wakatime";
};

programs.broot.enable = true;
# Respect XDG spec
file.".npmrc".text = ''
prefix=${config.xdg.dataHome}/npm
cache=${config.xdg.cacheHome}/npm
init-module=${config.xdg.configHome}/npm/config/npm-init.js
logs-dir=${config.xdg.stateHome}/npm/logs
'';

packages = with pkgs; [
authy
discord
spotify
thorium
geogebra6

# GUIs
cinnamon.nemo
transmission-gtk
gnome.gnome-disk-utility
greenlight
cura
blender
element-desktop

xdg-utils
rustup # TODO: not sure to keep rustup in path
spotify-tui

# CLI tools
bat
fd
delta
ripgrep
glow
fzf
btop
tealdeer
jq
calc

imv
mpv
wl-clipboard
wf-recorder
];
};

programs.yazi = {
enable = true;
xdg.configFile."tealdeer/config.toml".source = tomlFormat.generate "tealdeer-config" {
updates.auto_update = true;
};

enableBashIntegration = true;
enableFishIntegration = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};
programs.broot.enable = true;

programs.go = {
enable = true;
goPath = ".local/share/go";
};
programs.yazi = {
enable = true;

home.file.".cargo/config.toml".source = tomlFormat.generate "cargo-config" {
build.rustc-wrapper = getExe' pkgs.sccache "sccache";
enableBashIntegration = true;
enableFishIntegration = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};

source = {
local-mirror.registry = "sparse+http://local.crates.io:8080/index/";
# crates-io.replace-with = "local-mirror";
programs.go = {
enable = true;
goPath = ".local/share/go";
};

target = {
x86_64-unknown-linux-gnu = {
linker = getExe pkgs.llvmPackages.clang;
rustflags = [ "-Clink-arg=--ld-path=${getExe pkgs.mold}" "-Ctarget-cpu=native" ];
home.file.".cargo/config.toml".source = tomlFormat.generate "cargo-config" {
build.rustc-wrapper = getExe' pkgs.sccache "sccache";

source = {
local-mirror.registry = "sparse+http://local.crates.io:8080/index/";
# crates-io.replace-with = "local-mirror";
};
x86_64-apple-darwin.rustflags = [ "-Clink-arg=-fuse-ld=${getExe' pkgs.llvmPackages.lld "lld"}" "-Ctarget-cpu=native" ];
aarch64-apple-darwin.rustflags = [ "-Clink-arg=-fuse-ld=${getExe' pkgs.llvmPackages.lld "lld"}" "-Ctarget-cpu=native" ];
};

unstable.gc = true;
};
target = {
x86_64-unknown-linux-gnu = {
linker = getExe pkgs.llvmPackages.clang;
rustflags = [ "-Clink-arg=--ld-path=${getExe pkgs.mold}" "-Ctarget-cpu=native" ];
};
x86_64-apple-darwin.rustflags = [ "-Clink-arg=-fuse-ld=${getExe' pkgs.llvmPackages.lld "lld"}" "-Ctarget-cpu=native" ];
aarch64-apple-darwin.rustflags = [ "-Clink-arg=-fuse-ld=${getExe' pkgs.llvmPackages.lld "lld"}" "-Ctarget-cpu=native" ];
};

xdg.mimeApps = {
enable = true;
associations.added = {
"application/pdf" = [ "firefox.desktop" ];
unstable.gc = true;
};
defaultApplications = {
"application/pdf" = [ "firefox.desktop" ];
};
};

# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";

programs.firefox = {
enable = true;
package = (pkgs.firefox.override {
nativeMessagingHosts = with pkgs; [ tridactyl-native ];
});
profiles.default = {
isDefault = true;
settings = {
"browser.newtabpage.pinned" = [{ title = "NixOS"; url = "https://nixos.org"; }];
xdg.mimeApps = {
enable = true;
associations.added = {
"application/pdf" = [ "firefox.desktop" ];
};
defaultApplications = {
"application/pdf" = [ "firefox.desktop" ];
};
};
};
programs.qutebrowser.enable = true;

programs.kitty = {
enable = true;
settings = {
confirm_os_window_close = 0;
enable_audio_bell = "no";

# foreground = "#${config.colorScheme.colors.base05}";
# background = "#${config.colorScheme.colors.base00}";
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";

programs.firefox = {
enable = true;
package = (pkgs.firefox.override {
nativeMessagingHosts = with pkgs; [ tridactyl-native ];
});
profiles.default = {
isDefault = true;
settings = {
"browser.newtabpage.pinned" = [{ title = "NixOS"; url = "https://nixos.org"; }];
};
};
};
};
programs.qutebrowser.enable = true;

# TODO: configure
services.spotifyd.enable = true;
programs.kitty = {
enable = true;
settings = {
confirm_os_window_close = 0;
enable_audio_bell = "no";

programs.gpg.enable = true;
# foreground = "#${config.colorScheme.colors.base05}";
# background = "#${config.colorScheme.colors.base00}";
};
};

programs.topgrade = {
enable = true;
package = pkgs.unstable.topgrade;
settings = {
misc = {
# Don't ask for confirmations
assume_yes = true;
# TODO: configure
services.spotifyd.enable = true;

# Run `sudo -v` to cache credentials at the start of the run; this avoids a
# blocking password prompt in the middle of a possibly-unattended run.
pre_sudo = true;
programs.gpg.enable = true;

skip_notify = true;
disable = [ "rustup" ];
no_retry = true;
cleanup = true;
programs.topgrade = {
enable = true;
package = pkgs.unstable.topgrade;
settings = {
misc = {
# Don't ask for confirmations
assume_yes = true;

# Run `sudo -v` to cache credentials at the start of the run; this avoids a
# blocking password prompt in the middle of a possibly-unattended run.
pre_sudo = true;

skip_notify = true;
disable = [ "rustup" ];
no_retry = true;
cleanup = true;
};

# TODO: sepcify via global config
git.repos = [ "~/Developement/*/*" "~/.config/dotfiles" ];
};

# TODO: sepcify via global config
git.repos = [ "~/Developement/*/*" "~/.config/dotfiles" ];
};
};
}
22 changes: 22 additions & 0 deletions lib/unfree.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pkgs:

# List of all unfree packages authorized

let
inherit (builtins) elem;
inherit (pkgs.lib) getName;
in
package: elem (getName package) [
# NixOS
"steam"
"steam-original"
"steam-run"

# Home Manager
"authy"
"discord"
"spotify"
"thorium-browser"
"unrar"
"geogebra"
]
Loading

0 comments on commit 1d7c63d

Please sign in to comment.