From 533da03db0a7d6e77bf5a18a490e721d9ba06717 Mon Sep 17 00:00:00 2001 From: earnest ma Date: Sat, 14 Aug 2021 13:36:11 -0400 Subject: [PATCH] Limit graphical programs by hostname --- .config/nixpkgs/graphical.nix | 20 ++++++++++++++++++++ .config/nixpkgs/home.nix | 20 ++++++++------------ .config/nixpkgs/hostname.nix | 21 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 .config/nixpkgs/graphical.nix create mode 100644 .config/nixpkgs/hostname.nix diff --git a/.config/nixpkgs/graphical.nix b/.config/nixpkgs/graphical.nix new file mode 100644 index 0000000..9e57f9c --- /dev/null +++ b/.config/nixpkgs/graphical.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: + +let + pkgsUnstable = import {}; +in +{ + home.packages = with pkgs; [ + authy + barrier + pkgsUnstable.discord + google-chrome + todoist-electron + pkgsUnstable.zoom-us + + pkgsUnstable.logseq + sublime-music + + alacritty + ]; +} diff --git a/.config/nixpkgs/home.nix b/.config/nixpkgs/home.nix index 7e40c95..6c649f0 100644 --- a/.config/nixpkgs/home.nix +++ b/.config/nixpkgs/home.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: let + inherit (lib) optionals; + hostName = import ./hostname.nix lib; # Be able to use unstable packages pkgsUnstable = import {}; @@ -10,14 +12,12 @@ in home.username = "earne"; home.homeDirectory = "/home/earne"; - home.packages = with pkgs; [ - authy # non-free - barrier - pkgsUnstable.discord # non-free - google-chrome # non-free - todoist-electron # non-free - pkgsUnstable.zoom-us # non-free + imports = + (optionals (hostName == "tycho") [ + ./graphical.nix + ]); + home.packages = with pkgs; [ # Doom Emacs + dependencies pkgsUnstable.fd pkgsUnstable.ripgrep @@ -27,10 +27,6 @@ in isync khard - pkgsUnstable.logseq - sublime-music - - alacritty gitFull git-extras ghq diff --git a/.config/nixpkgs/hostname.nix b/.config/nixpkgs/hostname.nix new file mode 100644 index 0000000..849aef4 --- /dev/null +++ b/.config/nixpkgs/hostname.nix @@ -0,0 +1,21 @@ +lib: + +let + + inherit (builtins) currentSystem; + inherit (lib) maybeEnv fileContents; + inherit (lib.systems.elaborate { system = currentSystem; }) isLinux isDarwin; + +in + +maybeEnv "HOST" (fileContents ( + if !isDarwin then + /etc/hostname + else + derivation { + name = "hostname"; + system = currentSystem; + builder = "/bin/sh"; + args = [ "-c" "/usr/sbin/scutil --get LocalHostName > $out" ]; + } +))