Minor changes
- Redid the flake module to be based on extendModules instead - Added wrappers - Refactored code - Updated dependencies
This commit is contained in:
parent
9661927410
commit
ee7223ca36
19 changed files with 468 additions and 97 deletions
|
@ -4,6 +4,6 @@
|
|||
};
|
||||
|
||||
config.assets = {
|
||||
sshKeys = import ./ssh.nix {};
|
||||
sshKeys = import ./ssh.nix;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{...}: {
|
||||
{
|
||||
other = {
|
||||
bootstrap = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvSD7mNn5x+Ras/shxzyRMEhPqKeide3IH39UG6kLMV nikodem@rabulinski.com";
|
||||
};
|
||||
|
|
168
flake.lock
generated
168
flake.lock
generated
|
@ -26,6 +26,24 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"base16": {
|
||||
"inputs": {
|
||||
"fromYaml": "fromYaml"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689633990,
|
||||
"narHash": "sha256-iwvQg2Vx0IIDWZaKo8Xmzxlv1YPHg+Kp/QSv8dRv0RY=",
|
||||
"owner": "SenchoPens",
|
||||
"repo": "base16.nix",
|
||||
"rev": "dddf2e1c04845d43c89a8e9e37d574519649a404",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "SenchoPens",
|
||||
"repo": "base16.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"blobs": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -49,11 +67,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1691012184,
|
||||
"narHash": "sha256-AYxPkarxZPs18qSKPjT4t8flmgeyu3DcoLGMkeiWtvk=",
|
||||
"lastModified": 1692248770,
|
||||
"narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=",
|
||||
"owner": "lnl7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "d3529322dcaaddf0c50cb277c9c2a355f3a36a3b",
|
||||
"rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -91,11 +109,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1690739034,
|
||||
"narHash": "sha256-roW02IaiQ3gnEEDMCDWL5YyN+C4nBf/te6vfL7rG0jk=",
|
||||
"lastModified": 1693189188,
|
||||
"narHash": "sha256-o6otfsB/ecudboYFwiCeL49BX3/8vRC/XUZTgkaDx54=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "4015740375676402a2ee6adebc3c30ea625b9a94",
|
||||
"rev": "00169fe4a6015a88c3799f0bf89689e06a4d4896",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -136,6 +154,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_3": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
|
@ -156,6 +190,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fromYaml": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1689549921,
|
||||
"narHash": "sha256-iX0pk/uB019TdBGlaJEWvBCfydT6sRq+eDcGPifVsCM=",
|
||||
"owner": "SenchoPens",
|
||||
"repo": "fromYaml",
|
||||
"rev": "11fbbbfb32e3289d3c631e0134a23854e7865c84",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "SenchoPens",
|
||||
"repo": "fromYaml",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
@ -163,11 +213,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1690982105,
|
||||
"narHash": "sha256-32AzoLuwhtxBItcULRiCnxRfJcbVXbPZSH9TDVg21mU=",
|
||||
"lastModified": 1693399033,
|
||||
"narHash": "sha256-yXhiMo8MnE86sGtPIHAKaLHhmhe8v9tqGGotlUgKJvY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "b2ac1d2c32ac11b8d231d23622cdc4b2f28d07d2",
|
||||
"rev": "f5c15668f9842dd4d5430787d6aa8a28a07f7c10",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -270,11 +320,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1691003216,
|
||||
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
|
||||
"lastModified": 1693355128,
|
||||
"narHash": "sha256-+ZoAny3ZxLcfMaUoLVgL9Ywb/57wP+EtsdNGuXUJrwg=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4a56ce9727a0c5478a836a0d8a8f641c5b9a3d5f",
|
||||
"rev": "a63a64b593dcf2fe05f7c5d666eb395950f36bc9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -284,6 +334,26 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"racket": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1693462146,
|
||||
"narHash": "sha256-4UItztSrmmLc3+sSHh3CVcHuNRJupNsXCRKG00vpC/8=",
|
||||
"owner": "nrabulinski",
|
||||
"repo": "racket.nix",
|
||||
"rev": "e1f79a4db7a05e2ff139ac76c64ff5eb6b8d4fea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nrabulinski",
|
||||
"repo": "racket.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
|
@ -294,7 +364,36 @@
|
|||
"home-manager": "home-manager",
|
||||
"mailserver": "mailserver",
|
||||
"niko-nur": "niko-nur",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"racket": "racket",
|
||||
"stylix": "stylix",
|
||||
"wrapper-manager": "wrapper-manager",
|
||||
"wrapper-manager-hm-compat": "wrapper-manager-hm-compat"
|
||||
}
|
||||
},
|
||||
"stylix": {
|
||||
"inputs": {
|
||||
"base16": "base16",
|
||||
"flake-compat": "flake-compat_3",
|
||||
"home-manager": [
|
||||
"home-manager"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1691942466,
|
||||
"narHash": "sha256-bK6FFbsKtyLKJLwgHerWp/EMMoWqE0UJk0KEbgYICbY=",
|
||||
"owner": "danth",
|
||||
"repo": "stylix",
|
||||
"rev": "beb35709c9a769a5f279d3177af778a15dcbda46",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "danth",
|
||||
"repo": "stylix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
|
@ -326,6 +425,49 @@
|
|||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"wrapper-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1691847782,
|
||||
"narHash": "sha256-o442oJ4F6tcPYmd6wiC/lnjiq7r8ANa4vPpMGB3/MKk=",
|
||||
"owner": "viperML",
|
||||
"repo": "wrapper-manager",
|
||||
"rev": "ec1cf6abbf017bd17c3e24e8dddbefe4b445b569",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "viperML",
|
||||
"repo": "wrapper-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"wrapper-manager-hm-compat": {
|
||||
"inputs": {
|
||||
"home-manager": [
|
||||
"home-manager"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1693462186,
|
||||
"narHash": "sha256-q7TpkEPnzzp/6t/Gh/xxgrYmpctAb7ebGuHUpNfn+Gk=",
|
||||
"owner": "nrabulinski",
|
||||
"repo": "wrapper-manager-hm-compat",
|
||||
"rev": "199b04b07665b85649506c807e6a39d2adcfb133",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nrabulinski",
|
||||
"repo": "wrapper-manager-hm-compat",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
23
flake.nix
23
flake.nix
|
@ -11,6 +11,7 @@
|
|||
./assets
|
||||
./hosts
|
||||
./modules
|
||||
./wrappers
|
||||
./deploy.nix
|
||||
];
|
||||
|
||||
|
@ -69,6 +70,28 @@
|
|||
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
wrapper-manager = {
|
||||
url = "github:viperML/wrapper-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
wrapper-manager-hm-compat = {
|
||||
url = "github:nrabulinski/wrapper-manager-hm-compat";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
home-manager.follows = "home-manager";
|
||||
};
|
||||
};
|
||||
stylix = {
|
||||
url = "github:danth/stylix";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
home-manager.follows = "home-manager";
|
||||
};
|
||||
};
|
||||
racket = {
|
||||
url = "github:nrabulinski/racket.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
|
|
|
@ -5,26 +5,48 @@
|
|||
lib,
|
||||
...
|
||||
}: {
|
||||
mappers = {
|
||||
nixos = module: {
|
||||
modules = [
|
||||
inputs.agenix.nixosModules.age
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.mailserver.nixosModules.default
|
||||
self.nixosModules.settei
|
||||
{
|
||||
settei = {
|
||||
username = "niko";
|
||||
sane-defaults.enable = true;
|
||||
flake-qol = {
|
||||
enable = true;
|
||||
inherit inputs;
|
||||
};
|
||||
};
|
||||
}
|
||||
module
|
||||
];
|
||||
};
|
||||
builders = {
|
||||
nixos = name: module: let
|
||||
combinedInputs = inputs // {settei = self;};
|
||||
baseOptions = {
|
||||
settei.flake-qol = {
|
||||
enable = true;
|
||||
inputs = combinedInputs;
|
||||
};
|
||||
};
|
||||
base = inputs.nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
inputs.agenix.nixosModules.age
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.mailserver.nixosModules.default
|
||||
self.nixosModules.settei
|
||||
baseOptions
|
||||
];
|
||||
};
|
||||
defaultOptions = {
|
||||
username,
|
||||
inputs',
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
settei = {
|
||||
username = lib.mkDefault "niko";
|
||||
sane-defaults.enable = lib.mkDefault true;
|
||||
};
|
||||
|
||||
users.users.${username}.packages = lib.attrValues inputs'.settei.packages;
|
||||
};
|
||||
in
|
||||
base.extendModules {
|
||||
modules = [
|
||||
defaultOptions
|
||||
module
|
||||
];
|
||||
specialArgs = {
|
||||
prev = base;
|
||||
configurationName = name;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
|
|
|
@ -10,19 +10,24 @@
|
|||
username,
|
||||
...
|
||||
}: {
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
"${modulesPath}/profiles/qemu-guest.nix"
|
||||
(import ./disks.nix {})
|
||||
./disks.nix
|
||||
];
|
||||
boot = {
|
||||
supportedFilesystems = ["btrfs"];
|
||||
loader.systemd-boot.enable = true;
|
||||
loader.systemd-boot.configurationLimit = 1;
|
||||
loader.efi.canTouchEfiVariables = true;
|
||||
};
|
||||
|
||||
nixpkgs.system = "aarch64-linux";
|
||||
|
||||
users.users.${username}.openssh.authorizedKeys.keys = lib.attrValues config.assets.sshKeys.user;
|
||||
users.users.${username} = {
|
||||
openssh.authorizedKeys.keys = lib.attrValues config.assets.sshKeys.user;
|
||||
};
|
||||
|
||||
networking.domain = "hijiri";
|
||||
networking.hostName = "vm";
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{bootDevice ? "/dev/vda", ...}: {
|
||||
args: let
|
||||
bootDevice = args.bootDevice or "/dev/vda";
|
||||
in {
|
||||
disko.devices.disk.bootDisk = {
|
||||
type = "disk";
|
||||
device = bootDevice;
|
||||
|
@ -32,7 +34,10 @@
|
|||
inherit mountOptions;
|
||||
mountpoint = "/";
|
||||
};
|
||||
"/nix" = {inherit mountOptions;};
|
||||
"/nix" = {
|
||||
inherit mountOptions;
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
}: {
|
||||
imports = [
|
||||
"${modulesPath}/profiles/qemu-guest.nix"
|
||||
(import ./disks.nix {})
|
||||
./disks.nix
|
||||
|
||||
./conduit.nix
|
||||
./mail.nix
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{bootDevice ? "/dev/sda", ...}: {
|
||||
args: let
|
||||
bootDevice = args.bootDevice or "/dev/sda";
|
||||
in {
|
||||
disko.devices.disk.bootDisk = {
|
||||
type = "disk";
|
||||
device = bootDevice;
|
||||
|
@ -32,7 +34,10 @@
|
|||
inherit mountOptions;
|
||||
mountpoint = "/";
|
||||
};
|
||||
"/nix" = {inherit mountOptions;};
|
||||
"/nix" = {
|
||||
inherit mountOptions;
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{...}: {
|
||||
{
|
||||
imports = [
|
||||
./nixos
|
||||
./flake
|
||||
|
|
|
@ -10,11 +10,6 @@
|
|||
}: let
|
||||
inherit (lib) mkOption mapAttrs;
|
||||
inherit (flake-parts-lib) mkSubmoduleOptions;
|
||||
possibleConfigurations = {
|
||||
nixos = {};
|
||||
darwin = {};
|
||||
home = {};
|
||||
};
|
||||
in {
|
||||
_file = ./configurations.nix;
|
||||
|
||||
|
@ -24,29 +19,18 @@ in {
|
|||
builders = {
|
||||
nixos = mkOption {
|
||||
type = lib.types.functionTo lib.types.unspecified;
|
||||
default = nixpkgs.lib.nixosSystem;
|
||||
default = _name: nixpkgs.lib.nixosSystem;
|
||||
};
|
||||
darwin = mkOption {
|
||||
type = lib.types.functionTo lib.types.unspecified;
|
||||
default = darwin.lib.darwinSystem;
|
||||
default = _name: darwin.lib.darwinSystem;
|
||||
};
|
||||
home = mkOption {
|
||||
type = lib.types.functionTo lib.types.unspecified;
|
||||
default = home-manager.lib.homeManagerConfiguration;
|
||||
default = _name: home-manager.lib.homeManagerConfiguration;
|
||||
};
|
||||
};
|
||||
|
||||
# Those functions map the value of the configuration attribute
|
||||
# and emit a list of arguments to be passed to respected evalModules
|
||||
mappers =
|
||||
mapAttrs
|
||||
(_: _:
|
||||
mkOption {
|
||||
type = lib.types.functionTo lib.types.attrs;
|
||||
default = lib.id;
|
||||
})
|
||||
possibleConfigurations;
|
||||
|
||||
configurations = {
|
||||
nixos = mkOption {
|
||||
type = lib.types.unspecified;
|
||||
|
@ -61,42 +45,21 @@ in {
|
|||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
# This is exposed so that it's possible to modify the arguments that get passed to a builder
|
||||
# after they have been mapped. Probably shouldn't do it. Probably should remove it or make it read-only
|
||||
configurationOptions =
|
||||
mapAttrs
|
||||
(_: _:
|
||||
mkOption {
|
||||
type = lib.types.attrsOf lib.types.attrs;
|
||||
})
|
||||
possibleConfigurations;
|
||||
};
|
||||
|
||||
config = {
|
||||
configurationOptions =
|
||||
mapAttrs
|
||||
(
|
||||
name: _:
|
||||
mapAttrs
|
||||
(configurationName: val: let
|
||||
mapped = config.mappers.${name} val;
|
||||
# TODO: specialArgs is actually extraSpecialArgs in home-manager.
|
||||
# At which level should that be handled?
|
||||
defaultArgs = {
|
||||
specialArgs = {inherit configurationName;};
|
||||
};
|
||||
in
|
||||
lib.recursiveUpdate defaultArgs mapped)
|
||||
config.configurations.${name}
|
||||
)
|
||||
possibleConfigurations;
|
||||
|
||||
config.
|
||||
flake = {
|
||||
nixosConfigurations =
|
||||
mapAttrs
|
||||
(_: args: config.builders.nixos args)
|
||||
config.configurationOptions.nixos;
|
||||
};
|
||||
nixosConfigurations =
|
||||
mapAttrs
|
||||
config.builders.nixos
|
||||
config.configurations.nixos;
|
||||
darwinConfigurations =
|
||||
mapAttrs
|
||||
config.builders.darwin
|
||||
config.configurations.darwin;
|
||||
homeConfigurations =
|
||||
mapAttrs
|
||||
config.builders.home
|
||||
config.configurations.home;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -45,6 +45,16 @@
|
|||
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
|
||||
trusted-users = [username];
|
||||
auto-allocate-uids = true;
|
||||
extra-substituters = [
|
||||
"https://hyprland.cachix.org"
|
||||
"https://cache.garnix.io"
|
||||
"https://nix-community.cachix.org"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
|
||||
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
let
|
||||
keys = import ../assets/ssh.nix {};
|
||||
keys = import ../assets/ssh.nix;
|
||||
in {
|
||||
"leet-nrab-lol-pass.age".publicKeys = [keys.system.kazuki keys.other.bootstrap];
|
||||
"alert-nrab-lol-pass.age".publicKeys = [keys.system.kazuki keys.other.bootstrap];
|
||||
|
|
26
wrappers/default.nix
Normal file
26
wrappers/default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{inputs, ...}: {
|
||||
perSystem = {
|
||||
pkgs,
|
||||
inputs',
|
||||
...
|
||||
}: let
|
||||
argsModule = {
|
||||
_module.args = {
|
||||
inherit inputs';
|
||||
inherit inputs;
|
||||
};
|
||||
};
|
||||
wrapped = inputs.wrapper-manager.lib {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
inputs.wrapper-manager-hm-compat.wrapperManagerModules.homeManagerCompat
|
||||
argsModule
|
||||
./starship
|
||||
./helix
|
||||
./rash
|
||||
];
|
||||
};
|
||||
in {
|
||||
inherit (wrapped.config.build) packages;
|
||||
};
|
||||
}
|
44
wrappers/helix/default.nix
Normal file
44
wrappers/helix/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
programs.helix = {
|
||||
enable = true;
|
||||
settings = {
|
||||
editor = {
|
||||
true-color = true;
|
||||
line-number = "relative";
|
||||
mouse = false;
|
||||
cursor-shape.insert = "bar";
|
||||
color-modes = true;
|
||||
cursorline = true;
|
||||
auto-save = true;
|
||||
indent-guides.render = true;
|
||||
};
|
||||
};
|
||||
languages = {
|
||||
language = [
|
||||
{
|
||||
name = "koka";
|
||||
scope = "scope.koka";
|
||||
file-types = ["kk"];
|
||||
roots = [];
|
||||
indent = {
|
||||
tab-width = 4;
|
||||
unit = " ";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "racket";
|
||||
indent = {
|
||||
tab-width = 2;
|
||||
unit = " ";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
wrappers.helix.pathAdd = [pkgs.nil];
|
||||
}
|
56
wrappers/rash/default.nix
Normal file
56
wrappers/rash/default.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
pkgs,
|
||||
inputs',
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
wrappers.rash = let
|
||||
readlinePatched = pkgs.fetchFromGitHub {
|
||||
owner = "nrabulinski";
|
||||
repo = "readline";
|
||||
rev = "8eb52c163d6ea7c3cec2cc6b1011ce00738942e1";
|
||||
hash = "sha256-1yU0ZUBQqYEn85j4T2pLs02MTyJnO5BbYALIa88iomY=";
|
||||
};
|
||||
racket-with-libs = inputs'.racket.packages.racket.newLayer {
|
||||
withRacketPackages = ps:
|
||||
with ps; [
|
||||
readline-gpl
|
||||
(readline-lib.override {
|
||||
src = "${readlinePatched}/readline-lib";
|
||||
})
|
||||
rash
|
||||
threading
|
||||
functional
|
||||
racket-langserver
|
||||
|
||||
# TODO: Remove once dependency resolution is fixed
|
||||
slideshow-lib
|
||||
r5rs-lib
|
||||
data-enumerate-lib
|
||||
plot-lib
|
||||
plot-gui-lib
|
||||
plot-compat
|
||||
srfi-lib
|
||||
typed-racket-compatibility
|
||||
future-visualizer-pict
|
||||
macro-debugger-text-lib
|
||||
profile-lib
|
||||
images-gui-lib
|
||||
];
|
||||
buildInputs = with pkgs; [readline];
|
||||
};
|
||||
in {
|
||||
basePackage = pkgs.writeShellScriptBin "rash" ''
|
||||
exec "${racket-with-libs}/bin/rash-repl" "$@"
|
||||
'';
|
||||
env.
|
||||
XDG_CONFIG_HOME = pkgs.linkFarm "rash-config" {
|
||||
"rash/rashrc" = ./rashrc;
|
||||
"rash/rashrc.rkt" = ./rashrc.rkt;
|
||||
};
|
||||
pathAdd = [
|
||||
racket-with-libs
|
||||
config.wrappers.starship.wrapped
|
||||
];
|
||||
};
|
||||
}
|
17
wrappers/rash/rashrc
Normal file
17
wrappers/rash/rashrc
Normal file
|
@ -0,0 +1,17 @@
|
|||
(require readline/pread
|
||||
data/maybe
|
||||
(prefix-in f: data/functor)
|
||||
data/applicative
|
||||
data/monad
|
||||
threading
|
||||
|
||||
racket/string
|
||||
racket/cmdline
|
||||
racket/system
|
||||
racket/pretty
|
||||
racket/format
|
||||
racket/list
|
||||
racket/function
|
||||
racket/port)
|
||||
|
||||
(current-prompt-function prompt-f)
|
48
wrappers/rash/rashrc.rkt
Normal file
48
wrappers/rash/rashrc.rkt
Normal file
|
@ -0,0 +1,48 @@
|
|||
#lang racket
|
||||
|
||||
(require readline/pread
|
||||
data/maybe
|
||||
(prefix-in f: data/functor)
|
||||
data/applicative
|
||||
data/monad
|
||||
threading
|
||||
|
||||
racket/function
|
||||
racket/port)
|
||||
|
||||
(provide prompt-f)
|
||||
|
||||
(define (maybe-regexp-match* regexp str)
|
||||
(define res (regexp-match* regexp str #:match-select cadr))
|
||||
(if (empty? res) nothing (just (car res))))
|
||||
|
||||
(define (mfilter proc m)
|
||||
(chain (lambda (x) (if (proc x) m nothing)) m))
|
||||
|
||||
(define (run-cmd cmd . args)
|
||||
(define exe (find-executable-path cmd))
|
||||
(define proc (apply process* exe args))
|
||||
((fifth proc) 'wait)
|
||||
(define output (port->string (first proc)))
|
||||
(close-input-port (first proc))
|
||||
(close-output-port (second proc))
|
||||
(close-input-port (fourth proc))
|
||||
output)
|
||||
|
||||
(define (prompt-f #:last-return-value [last-ret #f])
|
||||
; TODO: Patch rash so that it throws an error without the need to parse the error message
|
||||
(define last-code
|
||||
(~>> (just last-ret)
|
||||
(mfilter exn:fail?)
|
||||
(f:map exn-message)
|
||||
(chain (lambda~>> (maybe-regexp-match* #rx"terminated with code ([0-9]+)")))))
|
||||
|
||||
; TODO: Don't show last-ret if it's this error ^^^^^^^^^^^^^^^
|
||||
(when (and last-ret (not (void? last-ret)))
|
||||
(display last-ret))
|
||||
(define prompt
|
||||
(run-cmd "starship"
|
||||
"prompt"
|
||||
; TODO: Set status to 1 if last-ret was some other exn
|
||||
(format "--status=~a" (from-just "0" last-code))))
|
||||
(readline-prompt (string->bytes/utf-8 prompt)))
|
5
wrappers/starship/default.nix
Normal file
5
wrappers/starship/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue