mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-08-16 23:40:54 +03:00
add support for Nix build with Flakes (#13)
* nix/flake: add support for x86_64-linux * nix/flake: cleanup * nix/flake: add qemu VM * qemu: fix hostname * qemu: cleanup * nix: add default.nix (for non flakes users) * qemu vm: enable X11 windowing system
This commit is contained in:
parent
9b6d6a5082
commit
3a9971d923
3
default.nix
Normal file
3
default.nix
Normal file
@ -0,0 +1,3 @@
|
||||
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
|
||||
src = builtins.fetchGit ./.;
|
||||
}).defaultNix
|
44
flake.lock
Normal file
44
flake.lock
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1629284811,
|
||||
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c5d161cc0af116a2e17f54316f0bf43f0819785c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"ref": "master",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1629366148,
|
||||
"narHash": "sha256-CIfmrcptxXiCVH9UCKRq44IHcSW8WQ8yQQPTavOpUF8=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b5c2212cdfceb727b072223e460eb7dcefbc4062",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "haskell-updates",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
33
flake.nix
Normal file
33
flake.nix
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
description = "A GUI library for writing native Haskell applications.";
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils/master";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/haskell-updates";
|
||||
};
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
with flake-utils.lib;
|
||||
eachSystem [ "x86_64-linux" ] (system:
|
||||
let
|
||||
version = with nixpkgs.lib;
|
||||
"${substring 0 8 self.lastModifiedDate}.${self.shortRev or "dirty"}";
|
||||
overlays = [
|
||||
(import ./nix/monomer.nix { inherit system version flake-utils; })
|
||||
(import ./nix/qemu.nix {
|
||||
inherit system version flake-utils nixpkgs;
|
||||
})
|
||||
];
|
||||
in with (import nixpkgs { inherit system overlays; }); rec {
|
||||
packages = flattenTree (recurseIntoAttrs {
|
||||
inherit (libraries) monomer;
|
||||
inherit (qemu) nixos;
|
||||
});
|
||||
apps = executables // {
|
||||
nixos = mkApp {
|
||||
drv = qemu.nixos;
|
||||
name = "run-nixos-vm";
|
||||
};
|
||||
};
|
||||
defaultPackage = packages.monomer;
|
||||
defaultApp = apps.tutorial;
|
||||
});
|
||||
}
|
53
nix/monomer.nix
Normal file
53
nix/monomer.nix
Normal file
@ -0,0 +1,53 @@
|
||||
{ system, version, flake-utils, ... }:
|
||||
self: super:
|
||||
with self;
|
||||
with haskell.lib;
|
||||
with flake-utils.lib;
|
||||
with super.haskellPackages.extend (self: super:
|
||||
with haskellPackages; rec {
|
||||
# nanovg = dontCheck (callHackage "nanovg" "0.8.0.0" {
|
||||
# inherit GLEW glew libGL libGLU;
|
||||
# inherit (xorg) libX11;
|
||||
# });
|
||||
|
||||
nanovg = dontCheck (callCabal2nixWithOptions "nanovg" (fetchFromGitHub {
|
||||
owner = "cocreature";
|
||||
repo = "nanovg-hs";
|
||||
rev = "cc8dfa0dc18a0792786c973b4e9a232fa7d3ecfd";
|
||||
sha256 = "0vvj4l2dfjqspl80bwq4vkcql5p7s5a7l1cv7vajkak0vn1ryy70";
|
||||
}) "-fexamples -fstb_truetype" {
|
||||
inherit GLEW glew libGL libGLU;
|
||||
inherit (xorg) libX11;
|
||||
});
|
||||
GLEW = glew;
|
||||
}); rec {
|
||||
libraries = recurseIntoAttrs {
|
||||
monomer = addExtraLibrary
|
||||
(overrideCabal (callCabal2nix "monomer" ../. { }) (o: {
|
||||
version = "${o.version}.${version}";
|
||||
doCheck = false;
|
||||
})) GLEW;
|
||||
};
|
||||
executables = {
|
||||
todo = mkApp rec {
|
||||
drv = libraries.monomer;
|
||||
name = "todo";
|
||||
};
|
||||
books = mkApp rec {
|
||||
drv = libraries.monomer;
|
||||
name = "books";
|
||||
};
|
||||
ticker = mkApp rec {
|
||||
drv = libraries.monomer;
|
||||
name = "ticker";
|
||||
};
|
||||
generative = mkApp rec {
|
||||
drv = libraries.monomer;
|
||||
name = "generative";
|
||||
};
|
||||
tutorial = mkApp rec {
|
||||
drv = libraries.monomer;
|
||||
name = "tutorial";
|
||||
};
|
||||
};
|
||||
}
|
103
nix/qemu.nix
Normal file
103
nix/qemu.nix
Normal file
@ -0,0 +1,103 @@
|
||||
{ system, version, flake-utils, nixpkgs, ... }:
|
||||
self: super:
|
||||
with self;
|
||||
with haskell.lib;
|
||||
with flake-utils.lib;
|
||||
with haskellPackages;
|
||||
let hostname = "nixos";
|
||||
in rec {
|
||||
qemu = recurseIntoAttrs {
|
||||
"${hostname}" = (import "${nixpkgs}/nixos" {
|
||||
inherit system;
|
||||
configuration = { config, pkgs, ... }:
|
||||
with (import ./monomer.nix { inherit system version flake-utils; } self
|
||||
super);
|
||||
let
|
||||
mkSystemAppFromLib = { library, app }:
|
||||
with pkgs; rec {
|
||||
bin = "${library}/bin/${app}";
|
||||
drv = runCommand "${library}-${app}" {
|
||||
buildInputs = [ makeWrapper ];
|
||||
} ''
|
||||
mkdir -pv $out/bin
|
||||
makeWrapper ${bin} $out/bin/${library}-${app}
|
||||
'';
|
||||
};
|
||||
|
||||
mkUser = { name, passwd ? "${name}" }: {
|
||||
"${name}" = {
|
||||
isNormalUser = true;
|
||||
createHome = true;
|
||||
password = "${passwd}";
|
||||
shell = fish;
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
};
|
||||
mkSystemPackages = { library, app }: [
|
||||
libraries."${library}"
|
||||
(mkSystemAppFromLib {
|
||||
library = libraries."${library}";
|
||||
inherit app;
|
||||
}).drv
|
||||
];
|
||||
in {
|
||||
networking = { hostName = hostname; };
|
||||
environment = {
|
||||
systemPackages = (with pkgs; [ htop ]) ++ (mkSystemPackages {
|
||||
library = "monomer";
|
||||
app = "todo";
|
||||
}) ++ (mkSystemPackages {
|
||||
library = "monomer";
|
||||
app = "books";
|
||||
}) ++ (mkSystemPackages {
|
||||
library = "monomer";
|
||||
app = "ticker";
|
||||
}) ++ (mkSystemPackages {
|
||||
library = "monomer";
|
||||
app = "generative";
|
||||
}) ++ (mkSystemPackages {
|
||||
library = "monomer";
|
||||
app = "tutorial";
|
||||
});
|
||||
};
|
||||
users = {
|
||||
mutableUsers = false;
|
||||
users = {
|
||||
root = { password = "root"; };
|
||||
inherit (mkUser { name = "monomer"; }) monomer;
|
||||
};
|
||||
};
|
||||
security = {
|
||||
sudo = {
|
||||
enable = true;
|
||||
wheelNeedsPassword = false;
|
||||
};
|
||||
};
|
||||
# Enable the X11 windowing system.
|
||||
services.xserver.enable = true;
|
||||
|
||||
# Enable the KDE Desktop Environment.
|
||||
services.xserver.displayManager.sddm.enable = true;
|
||||
services.xserver.desktopManager.plasma5.enable = true;
|
||||
services.xserver = {
|
||||
windowManager = {
|
||||
awesome = {
|
||||
enable = true;
|
||||
luaModules = [ luaPackages.luaposix ];
|
||||
};
|
||||
};
|
||||
};
|
||||
services.xserver.autorun = true;
|
||||
|
||||
virtualisation = {
|
||||
graphics = true;
|
||||
cores = 4;
|
||||
qemu.networkingOptions = [
|
||||
"-device virtio-net-pci,netdev=user.0"
|
||||
"-netdev type=user,id=user.0\${QEMU_NET_OPTS:+,$QEMU_NET_OPTS}"
|
||||
];
|
||||
};
|
||||
};
|
||||
}).vm;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user