summaryrefslogtreecommitdiff
path: root/modules/nixfiles/common/nix/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixfiles/common/nix/default.nix')
-rw-r--r--modules/nixfiles/common/nix/default.nix158
1 files changed, 158 insertions, 0 deletions
diff --git a/modules/nixfiles/common/nix/default.nix b/modules/nixfiles/common/nix/default.nix
new file mode 100644
index 0000000..4213a29
--- /dev/null
+++ b/modules/nixfiles/common/nix/default.nix
@@ -0,0 +1,158 @@
+{
+ config,
+ inputs,
+ lib,
+ pkgs,
+ pkgsPR,
+ pkgsRev,
+ this,
+ ...
+}:
+with lib; {
+ _module.args = let
+ importNixpkgs = nixpkgs:
+ import nixpkgs {
+ inherit (config.nixpkgs) localSystem crossSystem config;
+ };
+ in rec {
+ pkgsMaster = importNixpkgs inputs.nixpkgs-master;
+ pkgsStable = importNixpkgs inputs.nixpkgs-stable;
+ pkgsRev = rev: sha256:
+ importNixpkgs (pkgs.fetchFromGitHub {
+ owner = "NixOS";
+ repo = "nixpkgs";
+ inherit rev sha256;
+ });
+ pkgsPR = pr: pkgsRev "refs/pull/${toString pr}/head";
+ pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs";
+ };
+
+ nix = let
+ filteredInputs = filterAttrs (n: _: n != "self") inputs;
+ in {
+ # https://github.com/NixOS/nix/blob/master/src/libutil/experimental-features.cc
+ extraOptions = ''
+ extra-experimental-features = ca-derivations
+ extra-experimental-features = flakes
+ extra-experimental-features = nix-command
+ extra-experimental-features = recursive-nix
+ flake-registry = ${inputs.flake-registry}/flake-registry.json
+ keep-derivations = true
+ keep-outputs = true
+ warn-dirty = false
+ '';
+
+ nixPath =
+ mapAttrsToList (n: v: "${n}=${v}") filteredInputs
+ ++ ["nixfiles=${config.my.home}/src/nixfiles"];
+
+ registry =
+ mapAttrs (_: flake: {inherit flake;}) filteredInputs
+ // {
+ nixfiles.flake = inputs.self;
+ };
+
+ settings = {
+ trusted-users = ["root" "@wheel"];
+
+ substituters = [
+ "https://azahi.cachix.org"
+ "https://cachix.cachix.org"
+ "https://mic92.cachix.org"
+ "https://nix-community.cachix.org"
+ "https://pre-commit-hooks.cachix.org"
+ ];
+ trusted-public-keys = [
+ "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s="
+ "cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM="
+ "mic92.cachix.org-1:gi8IhgiT3CYZnJsaW7fxznzTkMUOn1RY4GmXdT/nXYQ="
+ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+ "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
+ ];
+ };
+ };
+
+ nixpkgs = {
+ overlays = with inputs; [
+ self.overlays.default
+ (_: super:
+ {
+ nix-bash-completions = super.nix-bash-completions.overrideAttrs (_: _: {
+ postPatch = ''
+ substituteInPlace _nix \
+ --replace 'nix nixos-option' 'nixos-option'
+ '';
+ });
+
+ alejandra = super.alejandra.overrideAttrs (_: _: {
+ patches = [./patches/alejandra-no-ads.patch];
+ });
+
+ # FIXME https://github.com/NixOS/nixpkgs/pull/187519
+ dendrite = super.dendrite.overrideAttrs (_: _: {
+ doCheck = false;
+ });
+ }
+ // (with super; let
+ np = nodePackages;
+ in {
+ dockerfile-language-server = np.dockerfile-language-server-nodejs;
+ editorconfig = editorconfig-core-c;
+ inherit (np) bash-language-server;
+ inherit (np) vim-language-server;
+ inherit (np) yaml-language-server;
+ json-language-server = np.vscode-json-languageserver;
+ k3d = kube3d;
+ lua-language-server = sumneko-lua-language-server;
+ nix-language-server = rnix-lsp;
+ omnisharp = omnisharp-roslyn;
+ tor-browser = tor-browser-bundle-bin;
+ }))
+ agenix.overlay
+ emacs-overlay.overlay
+ nur.overlay
+ xmonad-ng.overlays.default
+ ];
+
+ config.allowUnfree = true;
+ };
+
+ environment = {
+ sessionVariables.NIX_SHELL_PRESERVE_PROMPT = "1";
+
+ etc = {
+ nixpkgs.source = inputs.nixpkgs;
+
+ gc-roots.text =
+ concatMapStrings (x: x + "\n")
+ (with inputs; [nixpkgs nixpkgs-master nixpkgs-stable]);
+ };
+
+ systemPackages = with pkgs;
+ optionals config.profile.headful [
+ nix-top
+ nix-tree
+ ];
+ };
+
+ hm.home.file.".nix-defexpr/default.nix".text =
+ optionalString this.isHeadful
+ (
+ let
+ hostname = strings.escapeNixIdentifier this.hostname;
+ in ''
+ let
+ self = builtins.getFlake "nixfiles";
+ configurations = self.nixosConfigurations;
+ local = configurations.${hostname};
+ in rec {
+ inherit self;
+ inherit (self) inputs lib;
+ inherit (lib) my;
+ this = my.configurations.${hostname};
+ inherit (local) config;
+ inherit (local.config.system.build) toplevel vm vmWithBootLoader manual;
+ } // configurations // local._module.args
+ ''
+ );
+}