diff --git a/modules/darwin/community-builder/default.nix b/modules/darwin/community-builder/default.nix index 7c6e82331..cdb1bfb71 100644 --- a/modules/darwin/community-builder/default.nix +++ b/modules/darwin/community-builder/default.nix @@ -1,4 +1,9 @@ -{ inputs, pkgs, ... }: +{ + config, + inputs, + pkgs, + ... +}: { imports = [ "${inputs.self}/modules/shared/community-builder.nix" @@ -6,7 +11,29 @@ ./users.nix ]; + environment.etc.motd.text = config.nixCommunity.motd; + environment.systemPackages = [ pkgs.vim ]; + + launchd.daemons.nixpkgs-clone = { + environment = { + inherit (config.environment.variables) NIX_SSL_CERT_FILE; + }; + serviceConfig = { + StartCalendarInterval = [ + { + Hour = 0; + Minute = 0; + } + ]; + StandardErrorPath = "/var/log/nixpkgs-clone.log"; + StandardOutPath = "/var/log/nixpkgs-clone.log"; + }; + path = [ + pkgs.git + ]; + script = builtins.readFile "${inputs.self}/modules/shared/nixpkgs-clone.bash"; + }; } diff --git a/modules/nixos/community-builder/default.nix b/modules/nixos/community-builder/default.nix index 6825bebae..8c6508014 100644 --- a/modules/nixos/community-builder/default.nix +++ b/modules/nixos/community-builder/default.nix @@ -1,4 +1,9 @@ -{ inputs, pkgs, ... }: +{ + config, + inputs, + pkgs, + ... +}: { imports = [ "${inputs.self}/modules/shared/community-builder.nix" @@ -6,6 +11,8 @@ ./users.nix ]; + users.motd = config.nixCommunity.motd; + environment.systemPackages = [ # terminfo packages pkgs.foot.terminfo @@ -22,4 +29,13 @@ programs.fish.enable = true; # disable generated completion environment.etc."fish/generated_completions".text = pkgs.lib.mkForce ""; + + systemd.services.nixpkgs-clone = { + serviceConfig.Type = "oneshot"; + startAt = "daily"; + path = [ + pkgs.git + ]; + script = builtins.readFile "${inputs.self}/modules/shared/nixpkgs-clone.bash"; + }; } diff --git a/modules/shared/community-builder.nix b/modules/shared/community-builder.nix index 314c49741..63a352e4c 100644 --- a/modules/shared/community-builder.nix +++ b/modules/shared/community-builder.nix @@ -1,26 +1,43 @@ -{ pkgs, ... }: +{ lib, pkgs, ... }: { - # useful for people that want to test stuff - environment.systemPackages = [ - pkgs.fd - pkgs.git - pkgs.nano - pkgs.nix-output-monitor - pkgs.nix-tree - pkgs.nixpkgs-review - pkgs.ripgrep - pkgs.tig - ]; - - programs.nix-index-database.comma.enable = true; - - programs.zsh = { - enable = true; - # https://grml.org/zsh/grmlzshrc.html - # https://grml.org/zsh/grml-zsh-refcard.pdf - interactiveShellInit = '' - source ${pkgs.grml-zsh-config}/etc/zsh/zshrc + options.nixCommunity.motd = lib.mkOption { + type = lib.types.str; + description = "message of the day"; + }; + + config = { + nixCommunity.motd = '' + + Welcome to Nix Community! + + For a faster Nixpkgs clone use: + + git clone --reference /var/lib/nixpkgs.git https://github.com/NixOS/nixpkgs.git + ''; - promptInit = ""; # otherwise it'll override the grml prompt + + # useful for people that want to test stuff + environment.systemPackages = [ + pkgs.fd + pkgs.git + pkgs.nano + pkgs.nix-output-monitor + pkgs.nix-tree + pkgs.nixpkgs-review + pkgs.ripgrep + pkgs.tig + ]; + + programs.nix-index-database.comma.enable = true; + + programs.zsh = { + enable = true; + # https://grml.org/zsh/grmlzshrc.html + # https://grml.org/zsh/grml-zsh-refcard.pdf + interactiveShellInit = '' + source ${pkgs.grml-zsh-config}/etc/zsh/zshrc + ''; + promptInit = ""; # otherwise it'll override the grml prompt + }; }; } diff --git a/modules/shared/nixpkgs-clone.bash b/modules/shared/nixpkgs-clone.bash new file mode 100644 index 000000000..c3c75acf5 --- /dev/null +++ b/modules/shared/nixpkgs-clone.bash @@ -0,0 +1,5 @@ +CLONE_DIR="/var/lib/nixpkgs.git" +if [ ! -d "$CLONE_DIR" ]; then + git clone --bare https://github.com/NixOS/nixpkgs.git "$CLONE_DIR" +fi +git -C "$CLONE_DIR" -c remote.origin.fetch="+refs/heads/*:refs/remotes/origin/*" -c fetch.prune=true fetch