From 90a3549237df30bb4deda8f43277a0eb0ce5d152 Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Fri, 3 Mar 2023 00:18:20 -0700 Subject: [PATCH] use comma and pregenerated nix-index --- common/shell.nix | 46 ++++++++++++++++--------------- flake.lock | 70 +++++++++++++++++++++++++++--------------------- flake.nix | 37 ++++++++++++------------- 3 files changed, 83 insertions(+), 70 deletions(-) diff --git a/common/shell.nix b/common/shell.nix index db21657..d11f446 100644 --- a/common/shell.nix +++ b/common/shell.nix @@ -1,34 +1,24 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: # Improvements to the default shell -# - use nix-locate for command-not-found +# - use nix-index for command-not-found # - disable fish's annoying greeting message # - add some handy shell commands -let - nix-locate = config.inputs.nix-locate.packages.${config.currentSystem}.default; -in { - programs.command-not-found.enable = false; - - environment.systemPackages = [ - nix-locate +{ + environment.systemPackages = with pkgs; [ + comma ]; + # nix-index + programs.nix-index.enable = true; + programs.nix-index.enableFishIntegration = true; + programs.command-not-found.enable = false; + programs.fish = { enable = true; - shellInit = let - wrapper = pkgs.writeScript "command-not-found" '' - #!${pkgs.bash}/bin/bash - source ${nix-locate}/etc/profile.d/command-not-found.sh - command_not_found_handle "$@" - ''; - in '' - # use nix-locate for command-not-found functionality - function __fish_command_not_found_handler --on-event fish_command_not_found - ${wrapper} $argv - end - + shellInit = '' # disable annoying fish shell greeting set fish_greeting ''; @@ -43,4 +33,18 @@ in { io_rand_read = "nix run nixpkgs#fio -- --name TEST --eta-newline=5s --filename=temp.file --rw=randread --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=32 --runtime=60 --group_reporting; rm temp.file"; io_rand_write = "nix run nixpkgs#fio -- --name TEST --eta-newline=5s --filename=temp.file --rw=randrw --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=1 --runtime=60 --group_reporting; rm temp.file"; }; + + nixpkgs.overlays = [ + (final: prev: { + # comma uses the "nix-index" package built into nixpkgs by default. + # That package doesn't use the prebuilt nix-index database so it needs to be changed. + comma = prev.comma.overrideAttrs (old: { + postInstall = '' + wrapProgram $out/bin/comma \ + --prefix PATH : ${lib.makeBinPath [ prev.fzy config.programs.nix-index.package ]} + ln -s $out/bin/comma $out/bin/, + ''; + }); + }) + ]; } \ No newline at end of file diff --git a/flake.lock b/flake.lock index a27be31..bda597b 100644 --- a/flake.lock +++ b/flake.lock @@ -105,6 +105,31 @@ "type": "github" } }, + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "utils": [ + "simple-nixos-mailserver", + "utils" + ] + }, + "locked": { + "lastModified": 1674127017, + "narHash": "sha256-QO1xF7stu5ZMDLbHN30LFolMAwY6TVlzYvQoUs1RD68=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "8c9ea9605eed20528bf60fae35a2b613b901fd77", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -136,39 +161,38 @@ "type": "github" } }, - "nix-locate": { + "nix-index-database": { "inputs": { - "flake-compat": "flake-compat", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1673969751, - "narHash": "sha256-U6aYz3lqZ4NVEGEWiti1i0FyqEo4bUjnTAnA73DPnNU=", - "owner": "bennofs", - "repo": "nix-index", - "rev": "5f98881b1ed27ab6656e6d71b534f88430f6823a", + "lastModified": 1677382901, + "narHash": "sha256-2idFWlTVG+qUZkU2/W50amGSIxmN56igIkMAXKbv4S4=", + "owner": "Mic92", + "repo": "nix-index-database", + "rev": "4306fa7c12e098360439faac1a2e6b8e509ec97c", "type": "github" }, "original": { - "owner": "bennofs", - "repo": "nix-index", + "owner": "Mic92", + "repo": "nix-index-database", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1672580127, - "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", + "lastModified": 1677823547, + "narHash": "sha256-xD2qco8Pw8HAXgjf9OSi2H2N20WaTrtvgcl21525kVE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0874168639713f547c05947c76124f78441ea46c", + "rev": "78c4d33c16092e535bc4ba1284ba49e3e138483a", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.05", + "ref": "master", "repo": "nixpkgs", "type": "github" } @@ -188,22 +212,6 @@ "type": "indirect" } }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1675835843, - "narHash": "sha256-y1dSCQPcof4CWzRYRqDj4qZzbBl+raVPAko5Prdil28=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "32f914af34f126f54b45e482fb2da4ae78f3095f", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, "radio": { "inputs": { "flake-utils": [ @@ -250,10 +258,10 @@ "agenix": "agenix", "archivebox": "archivebox", "dailybuild_modules": "dailybuild_modules", + "deploy-rs": "deploy-rs", "flake-utils": "flake-utils", - "nix-locate": "nix-locate", + "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable", "radio": "radio", "radio-web": "radio-web", "simple-nixos-mailserver": "simple-nixos-mailserver" diff --git a/flake.nix b/flake.nix index 7951232..0ffbc35 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,9 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05"; - nixpkgs-unstable.url = "github:NixOS/nixpkgs/master"; + nixpkgs.url = "github:NixOS/nixpkgs/master"; flake-utils.url = "github:numtide/flake-utils"; - nix-locate.url = "github:bennofs/nix-index"; - nix-locate.inputs.nixpkgs.follows = "nixpkgs"; - # mail server simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-22.05"; simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs"; @@ -37,21 +33,26 @@ deploy-rs.url = "github:serokell/deploy-rs"; deploy-rs.inputs.nixpkgs.follows = "nixpkgs"; deploy-rs.inputs.utils.follows = "simple-nixos-mailserver/utils"; + + # prebuilt nix-index database + nix-index-database.url = "github:Mic92/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, nixpkgs-unstable, ... }@inputs: { + outputs = { self, nixpkgs, ... }@inputs: { nixosConfigurations = let - modules = system: [ + modules = system: with inputs; [ ./common - inputs.simple-nixos-mailserver.nixosModule - inputs.agenix.nixosModules.default - inputs.dailybuild_modules.nixosModule - inputs.archivebox.nixosModule + simple-nixos-mailserver.nixosModule + agenix.nixosModules.default + dailybuild_modules.nixosModule + archivebox.nixosModule + nix-index-database.nixosModules.nix-index ({ lib, ... }: { config.environment.systemPackages = [ - inputs.agenix.packages.${system}.agenix + agenix.packages.${system}.agenix ]; # because nixos specialArgs doesn't work for containers... need to pass in inputs a different way @@ -73,22 +74,22 @@ }; in { - "ray" = mkSystem "x86_64-linux" nixpkgs-unstable ./machines/ray/configuration.nix; - "nat" = mkSystem "aarch64-linux" nixpkgs ./machines/nat/configuration.nix; + "ray" = mkSystem "x86_64-linux" nixpkgs ./machines/ray/configuration.nix; + # "nat" = mkSystem "aarch64-linux" nixpkgs ./machines/nat/configuration.nix; "liza" = mkSystem "x86_64-linux" nixpkgs ./machines/liza/configuration.nix; "ponyo" = mkSystem "x86_64-linux" nixpkgs ./machines/ponyo/configuration.nix; - "router" = mkSystem "x86_64-linux" nixpkgs-unstable ./machines/router/configuration.nix; - "s0" = mkSystem "x86_64-linux" nixpkgs-unstable ./machines/storage/s0/configuration.nix; + "router" = mkSystem "x86_64-linux" nixpkgs ./machines/router/configuration.nix; + "s0" = mkSystem "x86_64-linux" nixpkgs ./machines/storage/s0/configuration.nix; }; packages = let mkKexec = system: - (nixpkgs-unstable.lib.nixosSystem { + (nixpkgs.lib.nixosSystem { inherit system; modules = [ ./machines/ephemeral/kexec.nix ]; }).config.system.build.kexec_tarball; mkIso = system: - (nixpkgs-unstable.lib.nixosSystem { + (nixpkgs.lib.nixosSystem { inherit system; modules = [ ./machines/ephemeral/iso.nix ]; }).config.system.build.isoImage;