lib.nix: put 'inputs' inside of 'flake' specialArgs

This commit is contained in:
Sridhar Ratnakumar 2023-03-15 13:46:51 -04:00
parent 2130b83070
commit 11286f0cfa
19 changed files with 50 additions and 51 deletions

View file

@ -1,4 +1,4 @@
{ pkgs, lib, inputs, system, ... }:
{ pkgs, lib, flake, system, ... }:
{
# on macOS, emacs can be launched via:
@ -8,7 +8,7 @@
enable = true;
package =
let
emacsPgtkWithXwidgets = inputs.emacs-overlay.packages.${system}.emacsPgtk.override {
emacsPgtkWithXwidgets = flake.inputs.emacs-overlay.packages.${system}.emacsPgtk.override {
withXwidgets = true;
};
myEmacs = emacsPgtkWithXwidgets.overrideAttrs (oa: {

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, system, ... }:
{
imports = [
./neovim/telescope.nix

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, system, ... }:
{
programs.neovim = {
coc = {

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, system, ... }:
{
programs.neovim = {
coc.settings.languageserver.haskell = {

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, flake, system, ... }:
{
programs.neovim = {
coc.settings.languageserver.rust = {
@ -16,7 +16,7 @@
plugin =
(pkgs.vimUtils.buildVimPlugin {
name = "coc-rust-analyzer";
src = inputs.coc-rust-analyzer;
src = flake.inputs.coc-rust-analyzer;
});
type = "lua";
config = ''

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, system, ... }:
{
programs.neovim = {
plugins = with pkgs.vimPlugins; [

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, system, ... }:
{
programs.neovim = {
plugins = with pkgs.vimPlugins; [

View file

@ -1,16 +1,16 @@
{ pkgs, inputs, system, ... }:
{ pkgs, flake, system, ... }:
{
programs.neovim = {
extraPackages = [
pkgs.zk
];
plugins = with pkgs.vimPlugins; [
plugins = [
{
plugin =
(pkgs.vimUtils.buildVimPlugin {
name = "zk-nvim";
src = inputs.zk-nvim;
src = flake.inputs.zk-nvim;
});
type = "lua";
config = ''

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, system, ... }:
{ pkgs, flake, system, ... }:
{
# Key packages required on nixos and macos
home.packages = with pkgs; [
@ -7,7 +7,7 @@
ripgrep
htop
inputs.comma.packages.${system}.default
flake.inputs.comma.packages.${system}.default
];
programs = {

View file

@ -1,7 +1,7 @@
{ pkgs, inputs, ... }:
{ pkgs, flake, ... }:
{
imports = [
"${inputs.nixos-vscode-server}/modules/vscode-server/home.nix"
"${flake.inputs.nixos-vscode-server}/modules/vscode-server/home.nix"
];
services.vscode-server.enable = true;

37
lib.nix
View file

@ -1,5 +1,19 @@
# Support code for this repo. This module could be made its own external repo.
{ self, inputs, config, ... }:
let
specialArgsFor = rec {
common = {
flake = { inherit inputs config; };
};
x86_64-linux = common // {
system = "x86_64-linux";
};
aarch64-darwin = common // {
system = "aarch64-darwin";
rosettaPkgs = import inputs.nixpkgs { system = "x86_64-darwin"; };
};
};
in
{
flake = {
# Linux home-manager module
@ -9,11 +23,7 @@
({
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs;
system = "x86_64-linux";
flake = { inherit config; };
};
home-manager.extraSpecialArgs = specialArgsFor.x86_64-linux;
})
];
};
@ -24,11 +34,7 @@
({
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs;
system = "aarch64-darwin";
flake = { inherit config; };
};
home-manager.extraSpecialArgs = specialArgsFor.aarch64-darwin;
})
];
};
@ -36,20 +42,13 @@
mkLinuxSystem = mod: inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
# Arguments to pass to all modules.
specialArgs = {
inherit system inputs;
flake = { inherit config; };
};
specialArgs = specialArgsFor.${system};
modules = [ mod ];
};
mkMacosSystem = mod: inputs.darwin.lib.darwinSystem rec {
system = "aarch64-darwin";
specialArgs = {
inherit inputs system;
flake = { inherit config; };
rosettaPkgs = import inputs.nixpkgs { system = "x86_64-darwin"; };
};
specialArgs = specialArgsFor.${system};
modules = [ mod ];
};
};

View file

@ -1,4 +1,4 @@
{ self, inputs, config, ... }:
{ self, config, ... }:
{
# Configuration common to all macOS systems
flake = {

View file

@ -1,9 +1,9 @@
{ keyName, domain }:
{ pkgs, lib, config, inputs, ... }:
{ pkgs, lib, config, flake, ... }:
{
imports = [
inputs.nix-serve-ng.nixosModules.default
flake.inputs.nix-serve-ng.nixosModules.default
];
# Cache server

View file

@ -1,6 +1,6 @@
{ pkgs, inputs, ... }: {
{ pkgs, flake, ... }: {
imports = [
inputs.nixos-vscode-server.nixosModules.system
flake.inputs.nixos-vscode-server.nixosModules.system
];
services.auto-fix-vscode-server.enable = true;

View file

@ -1,6 +1,6 @@
{ pkgs, inputs, system, flake, ... }:
{ pkgs, system, flake, ... }:
let
emanote = inputs.emanote.outputs.defaultPackage.${system};
emanote = flake.inputs.emanote.outputs.defaultPackage.${system};
in
{
# Global service, rather than user service, as the latter doesn't work in NixOS-WSL

View file

@ -1,4 +1,4 @@
{ pkgs, lib, inputs, system, ... }:
{ pkgs, lib, flake, system, ... }:
{
# TODO: use agenix to manage
@ -7,7 +7,7 @@
services.hercules-ci-agent = {
enable = true;
# nixpkgs may not always have the latest HCI.
package = inputs.hci.packages.${system}.hercules-ci-agent;
package = flake.inputs.hci.packages.${system}.hercules-ci-agent;
};
# Regularly optimize nix store if using CI, because CI use can produce *lots*

View file

@ -1,4 +1,4 @@
{ pkgs, inputs, flake, ... }: {
{ pkgs, flake, ... }: {
# For no-prompt Ctrl+Shift+B in VSCode
security.sudo.extraRules = [
{

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, system, flake, rosettaPkgs, ... }:
{ config, pkgs, lib, system, flake, rosettaPkgs, ... }:
{
environment.systemPackages = with pkgs; [
@ -11,8 +11,8 @@
gh
nixpkgs-fmt
emanote
inputs.hci.packages.${system}.hercules-ci-cli
inputs.nixpkgs-match.packages.${system}.default
flake.inputs.hci.packages.${system}.hercules-ci-cli
flake.inputs.nixpkgs-match.packages.${system}.default
# We must install Agda globally so that Doom-Emacs' agda config can
# recognize it. It doesn't matter that our projects use Nix/direnv.
@ -44,8 +44,8 @@
];
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # Enables use of `nix-shell -p ...` etc
registry.nixpkgs.flake = inputs.nixpkgs; # Make `nix shell` etc use pinned nixpkgs
nixPath = [ "nixpkgs=${flake.inputs.nixpkgs}" ]; # Enables use of `nix-shell -p ...` etc
registry.nixpkgs.flake = flake.inputs.nixpkgs; # Make `nix shell` etc use pinned nixpkgs
extraOptions = ''
extra-platforms = aarch64-darwin x86_64-darwin
experimental-features = nix-command flakes repl-flake

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, modulesPath, flake, ... }:
{ config, pkgs, lib, modulesPath, flake, ... }:
{
imports =