mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-06-18 03:09:37 +02:00
fix mzteinit on nix
This commit is contained in:
parent
4d713eef83
commit
1113554bf0
110
flake.lock
110
flake.lock
|
@ -1,81 +1,12 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"confgen": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"nixpkgs-zig-0-12": "nixpkgs-zig-0-12",
|
|
||||||
"utils": "utils"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1710099294,
|
|
||||||
"narHash": "sha256-u4TQiW0IODAjGRGy1igEQsaZ6P/xI+RVyzZqrCR4vfI=",
|
|
||||||
"ref": "a6fbe3c79eeed1dbda04a0be501fa2b95450a03f",
|
|
||||||
"rev": "a6fbe3c79eeed1dbda04a0be501fa2b95450a03f",
|
|
||||||
"revCount": 43,
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.mzte.de/LordMZTE/confgen"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"rev": "a6fbe3c79eeed1dbda04a0be501fa2b95450a03f",
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.mzte.de/LordMZTE/confgen"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709961763,
|
"lastModified": 1709961763,
|
||||||
"narHash": "sha256-6H95HGJHhEZtyYA3rIQpvamMKAGoa8Yh2rFV29QnuGw=",
|
"narHash": "sha256-6H95HGJHhEZtyYA3rIQpvamMKAGoa8Yh2rFV29QnuGw=",
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "3030f185ba6a4bf4f18b87f345f104e6a6961f34",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-zig-0-12": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1710092316,
|
|
||||||
"narHash": "sha256-96pThxPueCevkteIFsx2lMDcCjDrQtBfEbIJR2g+C5Q=",
|
|
||||||
"owner": "vancluever",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "add3752a30c1d9caa7614208afcb8e5502ce4407",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "vancluever",
|
|
||||||
"ref": "vancluever-zig-0-12",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-zig-0-12_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1710092316,
|
|
||||||
"narHash": "sha256-96pThxPueCevkteIFsx2lMDcCjDrQtBfEbIJR2g+C5Q=",
|
|
||||||
"owner": "vancluever",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "add3752a30c1d9caa7614208afcb8e5502ce4407",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "vancluever",
|
|
||||||
"ref": "vancluever-zig-0-12",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1709703039,
|
|
||||||
"narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=",
|
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d",
|
"rev": "3030f185ba6a4bf4f18b87f345f104e6a6961f34",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -87,10 +18,8 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"confgen": "confgen",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"utils": "utils"
|
||||||
"nixpkgs-zig-0-12": "nixpkgs-zig-0-12_2",
|
|
||||||
"utils": "utils_2"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
|
@ -108,21 +37,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utils": {
|
"utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
|
@ -140,24 +54,6 @@
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"utils_2": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1709126324,
|
|
||||||
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
10
flake.nix
10
flake.nix
|
@ -2,27 +2,19 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
confgen.url = "git+https://git.mzte.de/LordMZTE/confgen?rev=a6fbe3c79eeed1dbda04a0be501fa2b95450a03f";
|
|
||||||
nixpkgs-zig-0-12.url = "github:vancluever/nixpkgs/vancluever-zig-0-12";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ self
|
{ self
|
||||||
, nixpkgs
|
, nixpkgs
|
||||||
, utils
|
, utils
|
||||||
, confgen
|
|
||||||
, nixpkgs-zig-0-12
|
|
||||||
}: utils.lib.eachDefaultSystem (system:
|
}: utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
flakePkg = ref: (builtins.getFlake ref).packages.${system}.default;
|
flakePkg = ref: (builtins.getFlake ref).packages.${system}.default;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.mzteinit = import ./scripts/mzteinit/package.nix {
|
mzteinit = pkgs.callPackage ./scripts/mzteinit/package.nix { };
|
||||||
inherit pkgs;
|
|
||||||
confgen = confgen.packages.${system};
|
|
||||||
zig_0_12 = nixpkgs-zig-0-12.legacyPackages.${system}.zig_0_12;
|
|
||||||
};
|
|
||||||
# Local user nix env
|
# Local user nix env
|
||||||
packages.mzte-nix = pkgs.symlinkJoin {
|
packages.mzte-nix = pkgs.symlinkJoin {
|
||||||
name = "mzte-nix";
|
name = "mzte-nix";
|
||||||
|
|
|
@ -1,47 +1,28 @@
|
||||||
{ pkgs, confgen, zig_0_12 }:
|
{ pkgs, lib }:
|
||||||
let
|
{ setEnvironment ? null }:
|
||||||
deps = pkgs.linkFarm "zig-packages" [
|
pkgs.writeShellApplication {
|
||||||
# ansi-term
|
|
||||||
{
|
|
||||||
name = "1220ea86ace34b38e49c1d737c5f857d88346af10695a992b38e10cb0a73b6a19ef7";
|
|
||||||
path = pkgs.fetchgit {
|
|
||||||
url = "https://github.com/LordMZTE/ansi-term.git";
|
|
||||||
rev = "73c03175068679685535111dbea72cade075719e";
|
|
||||||
hash = "sha256-YeCZPUNciJz141HSHk4kBIfVYW/JqLflkKCjRHhIORk=";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
in
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
name = "mzteinit";
|
name = "mzteinit";
|
||||||
# TODO: WTF
|
|
||||||
src = ./../..;
|
|
||||||
dontBuild = true;
|
|
||||||
dontFixup = true;
|
|
||||||
|
|
||||||
configurePhase = ''
|
# We need a wrapper script here because nix cannot build mzteinit while taking localconf into
|
||||||
mkdir cgout
|
# account, as the builder has no access to the home directory. Thus, the user must build
|
||||||
# TODO: WTF
|
# mzteinit and we need to launch it here (before it's contained in $PATH, hence the absolute path).
|
||||||
sed -i 's#/usr/share/lua/5.4/fennel.lua#${pkgs.luajitPackages.fennel}/share/lua/5.1/fennel.lua#' confgen.lua
|
text = ''
|
||||||
${confgen.default}/bin/confgen --json-opt confgen.lua > cgout/opts.json
|
${lib.optionalString (setEnvironment != null) ''
|
||||||
|
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
. ${setEnvironment}
|
||||||
|
fi
|
||||||
|
'' }
|
||||||
|
mzteinit_path="$HOME"/.local/bin/mzteinit
|
||||||
|
if [[ -f "$mzteinit_path" ]]; then
|
||||||
|
exec $mzteinit_path
|
||||||
|
else
|
||||||
|
echo "mzteinit not found, starting pre-launch emergency shell!"
|
||||||
|
exec ${pkgs.bash}/bin/bash
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postPatch = ''
|
bashOptions = [ "errexit" "pipefail" ];
|
||||||
cd scripts/mzteinit
|
|
||||||
export ZIG_LOCAL_CACHE_DIR=$(pwd)/zig-cache
|
|
||||||
export ZIG_GLOBAL_CACHE_DIR=$ZIG_LOCAL_CACHE_DIR
|
|
||||||
mkdir -p $ZIG_GLOBAL_CACHE_DIR
|
|
||||||
ln -s ${deps} $ZIG_GLOBAL_CACHE_DIR/p
|
|
||||||
cd ../..
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
derivationArgs.passthru.shellPath = "/bin/mzteinit";
|
||||||
cd scripts/mzteinit
|
|
||||||
runHook preBuild
|
|
||||||
${zig_0_12}/bin/zig build install --prefix $out
|
|
||||||
runHook postBuild
|
|
||||||
cd ../..
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru.shellPath = "/bin/mzteinit";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,13 @@ pub fn populateEnvironment(env: *std.process.EnvMap) !bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set shell to fish to prevent anything from defaulting to mzteinit
|
// set shell to fish to prevent anything from defaulting to mzteinit
|
||||||
try env.put("SHELL", "/usr/bin/fish");
|
if (try util.findInPath(alloc, "fish")) |fish| {
|
||||||
|
defer alloc.free(fish);
|
||||||
|
try env.put("SHELL", fish);
|
||||||
|
} else {
|
||||||
|
log.warn("fish not found! setting $SHELL to /bin/sh", .{});
|
||||||
|
try env.put("SHELL", "/bin/sh");
|
||||||
|
}
|
||||||
|
|
||||||
// mix (elixir package manager) should respect XDG
|
// mix (elixir package manager) should respect XDG
|
||||||
try env.put("MIX_XDG", "1");
|
try env.put("MIX_XDG", "1");
|
||||||
|
|
|
@ -46,3 +46,30 @@ fn formatCommand(
|
||||||
pub fn fmtCommand(cmd: []const []const u8) std.fmt.Formatter(formatCommand) {
|
pub fn fmtCommand(cmd: []const []const u8) std.fmt.Formatter(formatCommand) {
|
||||||
return .{ .data = cmd };
|
return .{ .data = cmd };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn findInPath(alloc: std.mem.Allocator, bin: []const u8) !?[]const u8 {
|
||||||
|
const path = std.os.getenv("PATH") orelse return null;
|
||||||
|
|
||||||
|
var splits = std.mem.split(u8, path, ":");
|
||||||
|
while (splits.next()) |p| {
|
||||||
|
const trimmed = std.mem.trim(u8, p, " \n\r");
|
||||||
|
if (trimmed.len == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const joined = try std.fs.path.joinZ(
|
||||||
|
alloc,
|
||||||
|
&.{ trimmed, bin },
|
||||||
|
);
|
||||||
|
|
||||||
|
_ = std.fs.cwd().statFile(joined) catch |e| {
|
||||||
|
alloc.free(joined);
|
||||||
|
switch (e) {
|
||||||
|
error.FileNotFound, error.AccessDenied => continue,
|
||||||
|
else => return e,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return joined;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue