From 418ec7b94aa8202e5f5f0a59f2bb97a7c0510068 Mon Sep 17 00:00:00 2001 From: Kenny Ballou Date: Wed, 14 Oct 2020 10:05:44 -0600 Subject: dots: now for something completely different Use home-manager to configure user packages, dotfiles, and various other configurations. Add home-manager configuration for installing and managing user packages and profiles. Convert nearly all configuration to use home-manager to install and link configuration files. In no particular order of reference, I've used and/or referenced the following configurations and posts for this homeification: [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]. [0]: https://gitlab.com/NobbZ/nix-home-manager-dotfiles [1]: https://www.malloc47.com/migrating-to-nixos/ [2]: https://lucperkins.dev/blog/home-manager/ [3]: https://github.com/jwiegley/nix-config [4]: https://www.thedroneely.com/posts/declarative-user-package-management-in-nixos/ [5]: https://hugoreeves.com/posts/2019/nix-home/ [6]: https://rycee.gitlab.io/home-manager/ [7]: https://rycee.net/posts/2017-07-02-manage-your-home-with-nix.html [8]: https://github.com/abcdw/rde [9]: https://github.com/ryantm/dotfiles [10]: https://git.sr.ht/~vdemeester/home Signed-off-by: Kenny Ballou --- nix/overlays.nix | 14 ++++++++++++++ nix/sources.nix | 16 ++++++++++++++++ nix/utils.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 nix/overlays.nix create mode 100644 nix/sources.nix create mode 100644 nix/utils.nix (limited to 'nix') diff --git a/nix/overlays.nix b/nix/overlays.nix new file mode 100644 index 00000000..12e0e86d --- /dev/null +++ b/nix/overlays.nix @@ -0,0 +1,14 @@ +{ config, ... }: +{ + overlays = + let + paths = [ + ./overlays + ]; + in with builtins; + concatMap (path: + (map (n: import (path + ("/" + n))) + (filter (n: match ".*\\.nix" n != null || + pathExists (path + ("/" + n + "/default.nix"))) + (attrNames (readDir path))))) paths; +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 00000000..3e90ca06 --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,16 @@ +{ + nixpkgs = { + unstable = builtins.fetchGit { + url = "https://github.com/NixOS/nixpkgs.git"; + rev = "cf7475d2061ac3ada4b226571a4a1bb91420b578"; + }; + stable = builtins.fetchGit { + url = "https://github.com/NixOS/nixpkgs.git"; + rev = "c11f75bd73e8264bbca6f4bc969ccc39cd371196"; + }; + }; + home-manager = builtins.fetchGit { + url = "https://github.com/nix-community/home-manager.git"; + rev = "275d1b52126674764f0f3d15c73c2add511bd310"; + }; +} diff --git a/nix/utils.nix b/nix/utils.nix new file mode 100644 index 00000000..9848a785 --- /dev/null +++ b/nix/utils.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: +# https://stackoverflow.com/questions/42136197/how-to-override-compile-flags-for-a-single-package-in-nixos +let + overrideWithFlags = pkg: flags: + pkgs.lib.overrideDerivation pkg (old: + let + newflags = pkgs.lib.foldl' (acc: x: "${acc} ${x}") "" flags; + oldflags = if (pkgs.lib.hasAttr "NIX_CFLAGS_COMPILE" old) + then "${old.NIX_CFLAGS_COMPILE}" + else ""; + in + { + NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}"; + }); +in +{ + overrideWithFlags = overrideWithFlags; + optimizeForThisHost = pkg: + overrideWithFlags pkg [ "-O3" "-march=native" "-fPIC" ]; + + withDebugSymbols = pkg: + overrideWithFlags pkg [ "-DDEBUG" ]; + + importDirs = path: with builtins; + map (n: import (path + ("/" + n))) + (filter (n: match ".*\\.nix" n != null || + pathExists (path + ("/" + n + "/default.nix"))) + (attrNames (readDir path))); +} -- cgit v1.2.1