From e2f3e306fb4f76730a5bc8c7f3a96dab70f725c8 Mon Sep 17 00:00:00 2001 From: r2r-dev Date: Tue, 11 May 2021 20:45:40 +0200 Subject: [PATCH] Dirty hack to enable nixos-shell on macos https://github.com/NixOS/nixpkgs/issues/121903#issuecomment-836315774 https://github.com/NixOS/nixpkgs/pull/122420 https://github.com/Infinisil/nixpkgs/commit/4d244410ee0f3e3ece5494533217bbafbd95d9b3 https://github.com/NixOS/nixpkgs/issues/108984#issuecomment-819436585 https://github.com/dermetfan/nixos-shell/commit/28ea39e0b76698e7dbd198e9755d7dbc12bf5146 --- Makefile | 1 + bin/config.nix | 12 ++++++++++++ bin/nixos-shell | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 bin/config.nix diff --git a/Makefile b/Makefile index 2a6a321..5cf337e 100644 --- a/Makefile +++ b/Makefile @@ -23,4 +23,5 @@ test-efi: install: $(INSTALL) -D bin/nixos-shell $(DESTDIR)$(PREFIX)/bin/nixos-shell + $(INSTALL) -D bin/config.nix $(DESTDIR)$(PREFIX)/bin/config.nix $(INSTALL) -D share/nixos-shell/nixos-shell.nix $(DESTDIR)$(PREFIX)/share/nixos-shell/nixos-shell.nix diff --git a/bin/config.nix b/bin/config.nix new file mode 100644 index 0000000..9738c2f --- /dev/null +++ b/bin/config.nix @@ -0,0 +1,12 @@ +{ + virtualisation.qemu.pkgs = import { + system = "x86_64-darwin"; + overlays = [ + (self: super: { + qemu = super.qemu.overrideAttrs (attrs: { + preConfigure = attrs.preConfigure + "substituteInPlace meson.build --replace \'if exe_sign\' \'if false\'"; + }); + }) + ]; + }; +} diff --git a/bin/nixos-shell b/bin/nixos-shell index 0614880..8e30002 100755 --- a/bin/nixos-shell +++ b/bin/nixos-shell @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p bash coreutils set -euo pipefail @@ -54,6 +55,10 @@ trap cleanup EXIT SIGINT SIGQUIT ERR nix-build '' -A vm -k \ -I "nixos-config=${script_dir}/../share/nixos-shell/nixos-shell.nix" \ -o "${tempdir}/result" \ + --argstr system x86_64-linux \ + --arg configuration "${script_dir}/config.nix" \ + -I nixpkgs=http://github.com/SCOTT-HAMILTON/NixPkgs/archive/230f823cd985e499ff2fd450b419bc5b44c6dbf8.tar.gz \ + -I qnixpkgs=https://github.com/mroi/nixpkgs/archive/a180e45138f63f283b6d155bbd46367f09e29d1e.tar.gz \ "${extraBuildFlags[@]}" "$@" "${tempdir}/result/bin/"run-*-vm