nixfmt-rfc-style
There is nothing in this commit except for the changes made by nix-shell -p nixfmt-rfc-style --run "nixfmt ." If this has mucked up your open branches then sorry about that. You can probably nixfmt them to match before merging
This commit is contained in:
@@ -7,14 +7,26 @@
|
||||
lualinux,
|
||||
cpio,
|
||||
}:
|
||||
let pname = "anoia";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
pname = "anoia";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname;
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [ fennel cpio bc ];
|
||||
buildInputs = with lua.pkgs; [ linotify lualinux ];
|
||||
outputs = [ "out" "dev" ];
|
||||
nativeBuildInputs = [
|
||||
fennel
|
||||
cpio
|
||||
bc
|
||||
];
|
||||
buildInputs = with lua.pkgs; [
|
||||
linotify
|
||||
lualinux
|
||||
];
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
|
@@ -10,27 +10,35 @@
|
||||
fetch-freebsd,
|
||||
openssl,
|
||||
luaossl',
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "certifix-client";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "certifix-client";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [fetch-freebsd openssl lua];
|
||||
buildInputs = [
|
||||
fetch-freebsd
|
||||
openssl
|
||||
lua
|
||||
];
|
||||
|
||||
buildPhase = "";
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
fetch-freebsd
|
||||
fennel
|
||||
anoia
|
||||
lualinux
|
||||
luaossl'
|
||||
] ;
|
||||
mainFunction = "run";
|
||||
} ./${name}.fnl } $out/bin/${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
fetch-freebsd
|
||||
fennel
|
||||
anoia
|
||||
lualinux
|
||||
luaossl'
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./${name}.fnl
|
||||
} $out/bin/${name}
|
||||
'';
|
||||
}
|
||||
|
@@ -1,12 +1,20 @@
|
||||
{ callPackage, lib }:
|
||||
let
|
||||
typeChecked = caller: type: value:
|
||||
typeChecked =
|
||||
caller: type: value:
|
||||
let
|
||||
inherit (lib) types mergeDefinitions;
|
||||
defs = [{ file = caller; inherit value; }];
|
||||
defs = [
|
||||
{
|
||||
file = caller;
|
||||
inherit value;
|
||||
}
|
||||
];
|
||||
type' = types.submodule { options = type; };
|
||||
in (mergeDefinitions [] type' defs).mergedValue;
|
||||
in {
|
||||
in
|
||||
(mergeDefinitions [ ] type' defs).mergedValue;
|
||||
in
|
||||
{
|
||||
liminix = {
|
||||
builders = {
|
||||
squashfs = callPackage ./liminix-tools/builders/squashfs.nix { };
|
||||
@@ -14,27 +22,39 @@ in {
|
||||
uimage = callPackage ./kernel/uimage.nix { };
|
||||
kernel = callPackage ./kernel { };
|
||||
};
|
||||
outputRef = service : path :
|
||||
let h = { inherit service path; };
|
||||
in x : h.${x};
|
||||
callService = path : parameters :
|
||||
let pkg = callPackage path {};
|
||||
checkTypes = t : p : typeChecked (builtins.toString path) t p;
|
||||
in {
|
||||
outputRef =
|
||||
service: path:
|
||||
let
|
||||
h = { inherit service path; };
|
||||
in
|
||||
x: h.${x};
|
||||
callService =
|
||||
path: parameters:
|
||||
let
|
||||
pkg = callPackage path { };
|
||||
checkTypes = t: p: typeChecked (builtins.toString path) t p;
|
||||
in
|
||||
{
|
||||
inherit parameters;
|
||||
build = { dependencies ? [], ... } @ args :
|
||||
build =
|
||||
{
|
||||
dependencies ? [ ],
|
||||
...
|
||||
}@args:
|
||||
let
|
||||
s = pkg (checkTypes parameters
|
||||
(builtins.removeAttrs args ["dependencies"]));
|
||||
in s.overrideAttrs (o: {
|
||||
s = pkg (checkTypes parameters (builtins.removeAttrs args [ "dependencies" ]));
|
||||
in
|
||||
s.overrideAttrs (o: {
|
||||
dependencies = dependencies ++ o.dependencies;
|
||||
buildInputs = dependencies ++ o.buildInputs;
|
||||
});
|
||||
};
|
||||
lib = {
|
||||
types =
|
||||
let inherit (lib) mkOption types isDerivation;
|
||||
in rec {
|
||||
let
|
||||
inherit (lib) mkOption types isDerivation;
|
||||
in
|
||||
rec {
|
||||
service = types.package // {
|
||||
name = "service";
|
||||
description = "s6-rc service";
|
||||
@@ -46,10 +66,11 @@ in {
|
||||
description = "parametrisable s6-rc service definition";
|
||||
check = x: lib.isAttrs x && x ? parameters && x ? build;
|
||||
};
|
||||
replacable = t : types.either
|
||||
t
|
||||
# function might return a service or a path
|
||||
(types.functionTo types.anything);
|
||||
replacable =
|
||||
t:
|
||||
types.either t
|
||||
# function might return a service or a path
|
||||
(types.functionTo types.anything);
|
||||
};
|
||||
inherit typeChecked;
|
||||
};
|
||||
@@ -120,7 +141,7 @@ in {
|
||||
# vendor OS, or even to derisk Liminix updates on that device
|
||||
schnapps = callPackage ./schnapps { };
|
||||
|
||||
seedrng = callPackage ./seedrng {};
|
||||
seedrng = callPackage ./seedrng { };
|
||||
serviceFns = callPackage ./service-fns { };
|
||||
swconfig = callPackage ./swconfig { };
|
||||
systemconfig = callPackage ./systemconfig { };
|
||||
|
@@ -17,9 +17,16 @@ stdenv.mkDerivation {
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel "devout" {
|
||||
packages = [fennel anoia nellie lualinux];
|
||||
mainFunction = "run";
|
||||
} ./devout.fnl} $out/bin/devout
|
||||
cp -p ${
|
||||
writeFennel "devout" {
|
||||
packages = [
|
||||
fennel
|
||||
anoia
|
||||
nellie
|
||||
lualinux
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./devout.fnl
|
||||
} $out/bin/devout
|
||||
'';
|
||||
}
|
||||
|
@@ -3,12 +3,14 @@
|
||||
lua,
|
||||
fetchFromSourcehut,
|
||||
}:
|
||||
let pname = "fennel";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
pname = "fennel";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname;
|
||||
version = "1.3";
|
||||
nativeBuildInputs = [ lua ]; # used in build
|
||||
buildInputs = [ lua ]; # needed for patchShebangs
|
||||
nativeBuildInputs = [ lua ]; # used in build
|
||||
buildInputs = [ lua ]; # needed for patchShebangs
|
||||
src = fetchFromSourcehut {
|
||||
owner = "~technomancy";
|
||||
repo = pname;
|
||||
|
@@ -1,54 +1,58 @@
|
||||
{ lib
|
||||
, lua
|
||||
, lualinux
|
||||
, writeScriptBin
|
||||
, linotify
|
||||
, anoia
|
||||
, netlink-lua
|
||||
, fennel
|
||||
{
|
||||
lib,
|
||||
lua,
|
||||
lualinux,
|
||||
writeScriptBin,
|
||||
linotify,
|
||||
anoia,
|
||||
netlink-lua,
|
||||
fennel,
|
||||
}:
|
||||
let packages = [
|
||||
linotify
|
||||
anoia
|
||||
fennel
|
||||
lualinux
|
||||
netlink-lua
|
||||
lua.pkgs.readline
|
||||
];
|
||||
join = ps: builtins.concatStringsSep ";" ps;
|
||||
luapath = join (builtins.map (f:
|
||||
"${f}/share/lua/${lua.luaversion}/?.lua;" +
|
||||
"${f}/share/lua/${lua.luaversion}/?/init.lua"
|
||||
) packages);
|
||||
luacpath = join (builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so") packages);
|
||||
let
|
||||
packages = [
|
||||
linotify
|
||||
anoia
|
||||
fennel
|
||||
lualinux
|
||||
netlink-lua
|
||||
lua.pkgs.readline
|
||||
];
|
||||
join = ps: builtins.concatStringsSep ";" ps;
|
||||
luapath = join (
|
||||
builtins.map (
|
||||
f: "${f}/share/lua/${lua.luaversion}/?.lua;" + "${f}/share/lua/${lua.luaversion}/?/init.lua"
|
||||
) packages
|
||||
);
|
||||
luacpath = join (builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so") packages);
|
||||
|
||||
in writeScriptBin "fennelrepl" ''
|
||||
#!${lua}/bin/lua
|
||||
package.path = ${lib.strings.escapeShellArg luapath} .. ";" .. package.path
|
||||
package.cpath = ${lib.strings.escapeShellArg luacpath} .. ";" .. (package.cpath or "")
|
||||
local fennel = require "fennel"
|
||||
local specials = require("fennel.specials")
|
||||
table.insert(package.loaders or package.searchers,1, fennel.searcher)
|
||||
fennel['macro-path'] = "${anoia.dev}/share/lua/${lua.luaversion}/?.fnl;" .. fennel['macro-path']
|
||||
in
|
||||
writeScriptBin "fennelrepl" ''
|
||||
#!${lua}/bin/lua
|
||||
package.path = ${lib.strings.escapeShellArg luapath} .. ";" .. package.path
|
||||
package.cpath = ${lib.strings.escapeShellArg luacpath} .. ";" .. (package.cpath or "")
|
||||
local fennel = require "fennel"
|
||||
local specials = require("fennel.specials")
|
||||
table.insert(package.loaders or package.searchers,1, fennel.searcher)
|
||||
fennel['macro-path'] = "${anoia.dev}/share/lua/${lua.luaversion}/?.fnl;" .. fennel['macro-path']
|
||||
|
||||
local function eval_as_test(f)
|
||||
local g = (specials["make-compiler-env"]())._G
|
||||
g["RUNNING_TESTS"] = true
|
||||
return fennel.dofile(f, {correlate = true, compilerEnv = g})
|
||||
end
|
||||
local function eval_as_test(f)
|
||||
local g = (specials["make-compiler-env"]())._G
|
||||
g["RUNNING_TESTS"] = true
|
||||
return fennel.dofile(f, {correlate = true, compilerEnv = g})
|
||||
end
|
||||
|
||||
local more_fennel = os.getenv("FENNEL_PATH")
|
||||
if more_fennel then
|
||||
fennel.path = more_fennel .. ";" .. fennel.path
|
||||
end
|
||||
if #arg > 0 then
|
||||
if arg[1] == '--test' then
|
||||
eval_as_test(arg[2])
|
||||
else
|
||||
script = table.remove(arg, 1)
|
||||
fennel.dofile(script, {correlate = true}, arg)
|
||||
end
|
||||
local more_fennel = os.getenv("FENNEL_PATH")
|
||||
if more_fennel then
|
||||
fennel.path = more_fennel .. ";" .. fennel.path
|
||||
end
|
||||
if #arg > 0 then
|
||||
if arg[1] == '--test' then
|
||||
eval_as_test(arg[2])
|
||||
else
|
||||
fennel.repl()
|
||||
script = table.remove(arg, 1)
|
||||
fennel.dofile(script, {correlate = true}, arg)
|
||||
end
|
||||
''
|
||||
else
|
||||
fennel.repl()
|
||||
end
|
||||
''
|
||||
|
@@ -3,14 +3,15 @@
|
||||
stdenv,
|
||||
openssl,
|
||||
lua,
|
||||
fetchFromGitHub
|
||||
}: stdenv.mkDerivation {
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "fetch-freebsd";
|
||||
version = "v12.0.11";
|
||||
src = fetchFromGitHub {
|
||||
owner= "jrmarino";
|
||||
owner = "jrmarino";
|
||||
repo = "fetch-freebsd";
|
||||
rev = "v12.0.11";
|
||||
rev = "v12.0.11";
|
||||
hash = "sha256-nLNqjQFV9x2NntBdUlabxjS9q+er28zi8uXjWvCK2Ps=";
|
||||
};
|
||||
cmakeFlags = [
|
||||
@@ -22,7 +23,10 @@
|
||||
$CC -shared -o fetch-lua.so ${./lua-glue.c} -I$src -Llibrary -lssl -lfetch -llua
|
||||
'';
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ lua openssl ];
|
||||
buildInputs = [
|
||||
lua
|
||||
openssl
|
||||
];
|
||||
postInstall = ''
|
||||
rm -r $out/lib/lib*.a
|
||||
mkdir -p $out/lib/lua/${lua.luaversion}
|
||||
|
@@ -1,79 +1,94 @@
|
||||
{
|
||||
nftables
|
||||
, writeScript
|
||||
, lib
|
||||
} :
|
||||
name : ruleset :
|
||||
nftables,
|
||||
writeScript,
|
||||
lib,
|
||||
}:
|
||||
name: ruleset:
|
||||
let
|
||||
inherit (lib.strings) concatStringsSep splitString hasInfix substring;
|
||||
inherit (lib.strings)
|
||||
concatStringsSep
|
||||
splitString
|
||||
hasInfix
|
||||
substring
|
||||
;
|
||||
inherit (lib.lists) groupBy;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (builtins) map head tail;
|
||||
|
||||
indentLines = offset : lines :
|
||||
if lines == []
|
||||
then ""
|
||||
indentLines =
|
||||
offset: lines:
|
||||
if lines == [ ] then
|
||||
""
|
||||
else
|
||||
let
|
||||
line = head lines;
|
||||
isOpen = hasInfix "{" line;
|
||||
isClose = hasInfix "}" line;
|
||||
offset' = offset +
|
||||
(if isOpen then 4 else 0) +
|
||||
(if isClose then -4 else 0);
|
||||
offset' = offset + (if isOpen then 4 else 0) + (if isClose then -4 else 0);
|
||||
padding = offset: substring 0 offset " ";
|
||||
in
|
||||
if (isClose && !isOpen)
|
||||
then
|
||||
(padding offset') + line + "\n" + indentLines offset' (tail lines)
|
||||
else
|
||||
(padding offset) + line + "\n" + indentLines offset' (tail lines);
|
||||
if (isClose && !isOpen) then
|
||||
(padding offset') + line + "\n" + indentLines offset' (tail lines)
|
||||
else
|
||||
(padding offset) + line + "\n" + indentLines offset' (tail lines);
|
||||
|
||||
indent = text : indentLines 0 (splitString "\n" text);
|
||||
indent = text: indentLines 0 (splitString "\n" text);
|
||||
|
||||
dochain = { name, type, family, rules,
|
||||
policy ? null,
|
||||
priority ? "filter",
|
||||
hook ? null } : ''
|
||||
chain ${name} {
|
||||
${if hook != null
|
||||
then "type ${type} hook ${hook} priority ${priority}; policy ${policy};"
|
||||
else ""
|
||||
}
|
||||
${concatStringsSep "\n" rules}
|
||||
}
|
||||
'';
|
||||
dochain =
|
||||
{
|
||||
name,
|
||||
type,
|
||||
family,
|
||||
rules,
|
||||
policy ? null,
|
||||
priority ? "filter",
|
||||
hook ? null,
|
||||
}:
|
||||
''
|
||||
chain ${name} {
|
||||
${if hook != null then "type ${type} hook ${hook} priority ${priority}; policy ${policy};" else ""}
|
||||
${concatStringsSep "\n" rules}
|
||||
}
|
||||
'';
|
||||
|
||||
doset = { name, type, elements ? [], ... } : ''
|
||||
set ${name} {
|
||||
type ${type}
|
||||
${if elements != []
|
||||
then "elements = { ${concatStringsSep ", " elements } }"
|
||||
else ""
|
||||
}
|
||||
}
|
||||
'';
|
||||
doset =
|
||||
{
|
||||
name,
|
||||
type,
|
||||
elements ? [ ],
|
||||
...
|
||||
}:
|
||||
''
|
||||
set ${name} {
|
||||
type ${type}
|
||||
${if elements != [ ] then "elements = { ${concatStringsSep ", " elements} }" else ""}
|
||||
}
|
||||
'';
|
||||
|
||||
dochainorset =
|
||||
{ kind ? "chain", ... } @ params :
|
||||
{
|
||||
kind ? "chain",
|
||||
...
|
||||
}@params:
|
||||
{
|
||||
chain = dochain;
|
||||
set = doset;
|
||||
}.${kind} params;
|
||||
}
|
||||
.${kind}
|
||||
params;
|
||||
|
||||
dotable = family : chains : ''
|
||||
dotable = family: chains: ''
|
||||
table ${family} table-${family} {
|
||||
${concatStringsSep "\n" (map dochainorset chains)}
|
||||
}
|
||||
'';
|
||||
categorise = chains :
|
||||
groupBy
|
||||
({ family, ... } : family)
|
||||
(mapAttrsToList (n : v : { name = n; } // v ) chains);
|
||||
in writeScript name ''
|
||||
#!${nftables}/sbin/nft -f
|
||||
categorise =
|
||||
chains: groupBy ({ family, ... }: family) (mapAttrsToList (n: v: { name = n; } // v) chains);
|
||||
in
|
||||
writeScript name ''
|
||||
#!${nftables}/sbin/nft -f
|
||||
|
||||
flush ruleset
|
||||
flush ruleset
|
||||
|
||||
${indent (concatStringsSep "\n" (mapAttrsToList dotable (categorise ruleset)))}
|
||||
${indent (concatStringsSep "\n" (mapAttrsToList dotable (categorise ruleset)))}
|
||||
''
|
||||
|
@@ -1,6 +1,6 @@
|
||||
let
|
||||
drop = expr : "${expr} drop";
|
||||
accept = expr : "${expr} accept";
|
||||
drop = expr: "${expr} drop";
|
||||
accept = expr: "${expr} accept";
|
||||
mcast-scope = 8;
|
||||
allow-incoming = false;
|
||||
bogons-ip6 = {
|
||||
@@ -41,7 +41,7 @@ let
|
||||
"jump bogons-ip6"
|
||||
(drop "ip6 saddr ::1/128") # loopback address [RFC4291]
|
||||
(drop "ip6 daddr ::1/128")
|
||||
(drop "ip6 saddr ::FFFF:0:0/96")# IPv4-mapped addresses
|
||||
(drop "ip6 saddr ::FFFF:0:0/96") # IPv4-mapped addresses
|
||||
(drop "ip6 daddr ::FFFF:0:0/96")
|
||||
(drop "ip6 saddr fe80::/10") # link-local unicast
|
||||
(drop "ip6 daddr fe80::/10")
|
||||
@@ -57,7 +57,8 @@ let
|
||||
(drop
|
||||
# dest addr first byte 0xff, low nibble of second byte <= scope
|
||||
# https://www.mankier.com/8/nft#Payload_Expressions-Raw_Payload_Expression
|
||||
"@nh,192,8 eq 0xff @nh,204,4 le ${toString mcast-scope}")
|
||||
"@nh,192,8 eq 0xff @nh,204,4 le ${toString mcast-scope}"
|
||||
)
|
||||
|
||||
(accept "oifname \"int\" iifname \"ppp0\" meta l4proto udp ct state established,related")
|
||||
(accept "iifname \"int\" oifname \"ppp0\" meta l4proto udp")
|
||||
@@ -85,9 +86,11 @@ let
|
||||
# we can allow all reasonable inbound, or we can use an explicit
|
||||
# allowlist to enumerate the endpoints that are allowed to
|
||||
# accept inbound from the WAN
|
||||
(if allow-incoming
|
||||
then accept "oifname \"int\" iifname \"ppp0\""
|
||||
else "oifname \"int\" iifname \"ppp0\" jump incoming-allowed-ip6"
|
||||
(
|
||||
if allow-incoming then
|
||||
accept "oifname \"int\" iifname \"ppp0\""
|
||||
else
|
||||
"oifname \"int\" iifname \"ppp0\" jump incoming-allowed-ip6"
|
||||
)
|
||||
# allow all outbound and any inbound that's part of a
|
||||
# recognised (outbound-initiated) flow
|
||||
@@ -103,9 +106,11 @@ let
|
||||
rules = [
|
||||
"jump bogons-ip6"
|
||||
(accept "meta l4proto icmpv6")
|
||||
(if allow-incoming
|
||||
then accept "oifname \"int\" iifname \"ppp0\""
|
||||
else "oifname \"int\" iifname \"ppp0\" jump incoming-allowed-ip6"
|
||||
(
|
||||
if allow-incoming then
|
||||
accept "oifname \"int\" iifname \"ppp0\""
|
||||
else
|
||||
"oifname \"int\" iifname \"ppp0\" jump incoming-allowed-ip6"
|
||||
)
|
||||
(accept "oifname \"int\" iifname \"ppp0\" ct state established,related")
|
||||
(accept "iifname \"int\" oifname \"ppp0\" ")
|
||||
@@ -119,14 +124,21 @@ let
|
||||
"oifname \"int\" ip6 daddr 2001:8b0:de3a:40de::e9d tcp dport 22"
|
||||
];
|
||||
};
|
||||
in {
|
||||
inherit input-ip6 forward-ip6 bogons-ip6 incoming-allowed-ip6;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
input-ip6
|
||||
forward-ip6
|
||||
bogons-ip6
|
||||
incoming-allowed-ip6
|
||||
;
|
||||
lan-set-ip = {
|
||||
kind = "set";
|
||||
family = "ip";
|
||||
type = "ifname";
|
||||
elements = [
|
||||
"eth0" "eth1"
|
||||
"eth0"
|
||||
"eth1"
|
||||
];
|
||||
|
||||
};
|
||||
@@ -136,7 +148,8 @@ in {
|
||||
family = "ip6";
|
||||
type = "ifname";
|
||||
elements = [
|
||||
"eth0" "eth1"
|
||||
"eth0"
|
||||
"eth1"
|
||||
];
|
||||
|
||||
};
|
||||
|
@@ -1,4 +1,5 @@
|
||||
let
|
||||
pkgs = import <nixpkgs> { overlays = [( import ../../overlay.nix)]; };
|
||||
pkgs = import <nixpkgs> { overlays = [ (import ../../overlay.nix) ]; };
|
||||
ruleset = import ./test-rules-min.nix;
|
||||
in pkgs.firewallgen "firewall.nft" ruleset
|
||||
in
|
||||
pkgs.firewallgen "firewall.nft" ruleset
|
||||
|
@@ -1,8 +1,9 @@
|
||||
{ stdenv
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, zlib
|
||||
, openssl
|
||||
{
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
cmake,
|
||||
zlib,
|
||||
openssl,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
stdenv
|
||||
, fetchurl
|
||||
stdenv,
|
||||
fetchurl,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
name = "gen_init_cpio";
|
||||
|
@@ -1,27 +1,31 @@
|
||||
# A "hello world" program that's smaller than the GNU
|
||||
# one. Used for testing the toolchain/linker behaviour.
|
||||
{
|
||||
runCommandCC
|
||||
runCommandCC,
|
||||
}:
|
||||
let code = ''
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
let
|
||||
code = ''
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
printf("hello world\n");
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
runCommandCC "hello"
|
||||
{
|
||||
printf("hello world\n");
|
||||
return 0;
|
||||
name = "hi";
|
||||
inherit code;
|
||||
executable = true;
|
||||
# hardeningDisable = ["all"];
|
||||
passAsFile = [ "code" ];
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
}
|
||||
'';
|
||||
in runCommandCC "hello" {
|
||||
name = "hi";
|
||||
inherit code;
|
||||
executable = true;
|
||||
# hardeningDisable = ["all"];
|
||||
passAsFile = ["code"];
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
} ''
|
||||
n=$out/bin/$name
|
||||
mkdir -p "$(dirname "$n")"
|
||||
mv "$codePath" code.c
|
||||
$CC -x c code.c -o "$n"
|
||||
''
|
||||
''
|
||||
n=$out/bin/$name
|
||||
mkdir -p "$(dirname "$n")"
|
||||
mv "$codePath" code.c
|
||||
$CC -x c code.c -o "$n"
|
||||
''
|
||||
|
@@ -8,7 +8,10 @@ runCommand "ifwait" { } ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${
|
||||
writeFennel "ifwait" {
|
||||
packages = [ anoia netlink-lua ];
|
||||
packages = [
|
||||
anoia
|
||||
netlink-lua
|
||||
];
|
||||
} ./ifwait.fnl
|
||||
} $out/bin/ifwait
|
||||
''
|
||||
|
@@ -7,29 +7,33 @@
|
||||
lua,
|
||||
anoia,
|
||||
lualinux,
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "incz";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "incz";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [lua];
|
||||
nativeBuildInputs = [fennelrepl];
|
||||
buildInputs = [ lua ];
|
||||
nativeBuildInputs = [ fennelrepl ];
|
||||
|
||||
buildPhase = ''
|
||||
fennelrepl --test ./incz.fnl
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
fennel
|
||||
];
|
||||
macros = [
|
||||
anoia.dev
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./incz.fnl } ${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
fennel
|
||||
];
|
||||
macros = [
|
||||
anoia.dev
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./incz.fnl
|
||||
} ${name}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
@@ -19,7 +19,8 @@ let
|
||||
${busybox}/bin/sh
|
||||
'';
|
||||
refs = writeReferencesToFile busybox;
|
||||
in runCommand "initramfs.cpio" { } ''
|
||||
in
|
||||
runCommand "initramfs.cpio" { } ''
|
||||
cat << SPECIALS | ${gen_init_cpio}/bin/gen_init_cpio /dev/stdin > out
|
||||
dir /proc 0755 0 0
|
||||
dir /sys 0755 0 0
|
||||
|
@@ -11,27 +11,36 @@
|
||||
fetch-freebsd,
|
||||
openssl,
|
||||
rxi-json,
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "json-to-fstree";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "json-to-fstree";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [fetch-freebsd rxi-json openssl lua];
|
||||
buildInputs = [
|
||||
fetch-freebsd
|
||||
rxi-json
|
||||
openssl
|
||||
lua
|
||||
];
|
||||
|
||||
buildPhase = "";
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
fetch-freebsd
|
||||
rxi-json
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
] ;
|
||||
mainFunction = "run";
|
||||
} ./${name}.fnl } $out/bin/${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
fetch-freebsd
|
||||
rxi-json
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./${name}.fnl
|
||||
} $out/bin/${name}
|
||||
'';
|
||||
}
|
||||
|
@@ -45,11 +45,12 @@ let
|
||||
# hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
# })#
|
||||
./gentree-writable-outputs.patch
|
||||
# ./update-usb-sg-backport-patch.patch
|
||||
# ./backport_kfree_sensitive.patch
|
||||
# ./update-usb-sg-backport-patch.patch
|
||||
# ./backport_kfree_sensitive.patch
|
||||
];
|
||||
};
|
||||
in stdenv.mkDerivation rec {
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
inherit donorTree;
|
||||
KERNEL_VERSION = builtins.substring 0 11 donorTree.rev;
|
||||
BACKPORTS_VERSION = backports.version;
|
||||
@@ -59,10 +60,15 @@ in stdenv.mkDerivation rec {
|
||||
# and I don't have the patience to patch it out. There is no other
|
||||
# reason we need either of them as build inputs.
|
||||
depsBuildBuild = [ coccinelle ];
|
||||
nativeBuildInputs = [ which git python2 ];
|
||||
nativeBuildInputs = [
|
||||
which
|
||||
git
|
||||
python2
|
||||
];
|
||||
|
||||
phases = [
|
||||
"backportFromFuture" "installPhase"
|
||||
"backportFromFuture"
|
||||
"installPhase"
|
||||
];
|
||||
|
||||
backportFromFuture = ''
|
||||
|
@@ -34,9 +34,9 @@ stdenv.mkDerivation rec {
|
||||
perl
|
||||
]);
|
||||
CC = "${stdenv.cc.bintools.targetPrefix}gcc";
|
||||
HOSTCC = with buildPackages.pkgs;
|
||||
"gcc -I${openssl}/include -I${ncurses}/include";
|
||||
HOST_EXTRACFLAGS = with buildPackages.pkgs;
|
||||
HOSTCC = with buildPackages.pkgs; "gcc -I${openssl}/include -I${ncurses}/include";
|
||||
HOST_EXTRACFLAGS =
|
||||
with buildPackages.pkgs;
|
||||
"-I${openssl.dev}/include -L${openssl.out}/lib -L${ncurses.out}/lib";
|
||||
PKG_CONFIG_PATH = "./pkgconfig";
|
||||
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
|
||||
@@ -45,7 +45,12 @@ stdenv.mkDerivation rec {
|
||||
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
outputs = ["out" "headers" "modulesupport" "config"] ++ targetNames;
|
||||
outputs = [
|
||||
"out"
|
||||
"headers"
|
||||
"modulesupport"
|
||||
"config"
|
||||
] ++ targetNames;
|
||||
phases = [
|
||||
"unpackPhase"
|
||||
"butcherPkgconfig"
|
||||
@@ -61,8 +66,7 @@ stdenv.mkDerivation rec {
|
||||
patches = [
|
||||
./cmdline-cookie.patch
|
||||
./mips-malta-fdt-from-bootloader.patch
|
||||
] ++ lib.optional (lib.versionOlder version "5.18.0")
|
||||
./phram-allow-cached-mappings.patch;
|
||||
] ++ lib.optional (lib.versionOlder version "5.18.0") ./phram-allow-cached-mappings.patch;
|
||||
|
||||
# this is here to work around what I think is a bug in nixpkgs
|
||||
# packaging of ncurses: it installs pkg-config data files which
|
||||
|
@@ -1,24 +1,25 @@
|
||||
{
|
||||
stdenv
|
||||
, dtc
|
||||
, lib
|
||||
, runCommand
|
||||
, writeText
|
||||
stdenv,
|
||||
dtc,
|
||||
lib,
|
||||
runCommand,
|
||||
writeText,
|
||||
}:
|
||||
{ dts
|
||||
, includes
|
||||
, commandLine
|
||||
}:let
|
||||
{
|
||||
dts,
|
||||
includes,
|
||||
commandLine,
|
||||
}:
|
||||
let
|
||||
cppDtSearchFlags = builtins.concatStringsSep " " (map (f: "-I${f}") includes);
|
||||
dtcSearchFlags = builtins.concatStringsSep " " (map (f: "-i${f}") includes);
|
||||
cmdline = lib.concatStringsSep " " commandLine;
|
||||
chosen = writeText "chosen.dtsi" "/{ chosen { bootargs = ${builtins.toJSON cmdline}; }; };";
|
||||
combined = writeText "combined-dts-fragments"
|
||||
(lib.concatStrings
|
||||
(builtins.map
|
||||
(f: "#include \"${f}\"\n")
|
||||
(dts ++ [ chosen ])));
|
||||
in stdenv.mkDerivation {
|
||||
combined = writeText "combined-dts-fragments" (
|
||||
lib.concatStrings (builtins.map (f: "#include \"${f}\"\n") (dts ++ [ chosen ]))
|
||||
);
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "dtb";
|
||||
phases = [ "buildPhase" ];
|
||||
nativeBuildInputs = [ dtc ];
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{
|
||||
lzma
|
||||
, stdenv
|
||||
, ubootTools
|
||||
, dtc
|
||||
, lib
|
||||
} :
|
||||
lzma,
|
||||
stdenv,
|
||||
ubootTools,
|
||||
dtc,
|
||||
lib,
|
||||
}:
|
||||
let
|
||||
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
|
||||
arch = stdenv.hostPlatform.linuxArch;
|
||||
@@ -12,21 +12,29 @@ let
|
||||
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
|
||||
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
|
||||
'';
|
||||
in {
|
||||
kernel
|
||||
, commandLine
|
||||
, commandLineDtbNode ? "bootargs"
|
||||
, entryPoint
|
||||
, extraName ? "" # e.g. socFamily
|
||||
, loadAddress
|
||||
, imageFormat
|
||||
, alignment ? null
|
||||
, dtb ? null
|
||||
} : stdenv.mkDerivation {
|
||||
in
|
||||
{
|
||||
kernel,
|
||||
commandLine,
|
||||
commandLineDtbNode ? "bootargs",
|
||||
entryPoint,
|
||||
extraName ? "", # e.g. socFamily
|
||||
loadAddress,
|
||||
imageFormat,
|
||||
alignment ? null,
|
||||
dtb ? null,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "kernel.image";
|
||||
phases = [
|
||||
"preparePhase"
|
||||
(if commandLine != null then assert dtb != null; "mungeDtbPhase" else ":")
|
||||
(
|
||||
if commandLine != null then
|
||||
assert dtb != null;
|
||||
"mungeDtbPhase"
|
||||
else
|
||||
":"
|
||||
)
|
||||
(if imageFormat == "fit" then "buildPhaseFIT" else "buildPhaseUImage")
|
||||
"installPhase"
|
||||
];
|
||||
@@ -71,7 +79,9 @@ in {
|
||||
};
|
||||
};
|
||||
_VARS
|
||||
mkimage -f mkimage.its -E ${lib.optionalString (alignment != null) "-B 0x${lib.toHexString alignment}"} kernel.uimage
|
||||
mkimage -f mkimage.its -E ${
|
||||
lib.optionalString (alignment != null) "-B 0x${lib.toHexString alignment}"
|
||||
} kernel.uimage
|
||||
mkimage -l kernel.uimage
|
||||
'';
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
{
|
||||
lib
|
||||
, writeText
|
||||
lib,
|
||||
writeText,
|
||||
}:
|
||||
name : config: writeText name
|
||||
(builtins.concatStringsSep
|
||||
"\n"
|
||||
(lib.mapAttrsToList
|
||||
(name: value: (if value == "n" then "# CONFIG_${name} is not set" else "CONFIG_${name}=${value}"))
|
||||
config
|
||||
))
|
||||
name: config:
|
||||
writeText name (
|
||||
builtins.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (
|
||||
name: value: (if value == "n" then "# CONFIG_${name} is not set" else "CONFIG_${name}=${value}")
|
||||
) config
|
||||
)
|
||||
)
|
||||
|
@@ -10,33 +10,39 @@
|
||||
let
|
||||
inherit (liminix.services) oneshot;
|
||||
inherit (lib) concatStringsSep;
|
||||
loader = runCommand "modules" {
|
||||
nativeBuildInputs = with pkgsBuildBuild ;[
|
||||
kmod cpio gawk
|
||||
];
|
||||
} ''
|
||||
kernel=${kernel.modulesupport}
|
||||
loader =
|
||||
runCommand "modules"
|
||||
{
|
||||
nativeBuildInputs = with pkgsBuildBuild; [
|
||||
kmod
|
||||
cpio
|
||||
gawk
|
||||
];
|
||||
}
|
||||
''
|
||||
kernel=${kernel.modulesupport}
|
||||
|
||||
mkdir -p lib/modules/0.0
|
||||
(cd $kernel && find . -name \*.ko | cpio --verbose --make-directories -p $NIX_BUILD_TOP/lib/modules/0.0)
|
||||
cp $kernel/modules.* lib/modules/0.0
|
||||
depmod -b . 0.0
|
||||
mkdir -p lib/modules/0.0
|
||||
(cd $kernel && find . -name \*.ko | cpio --verbose --make-directories -p $NIX_BUILD_TOP/lib/modules/0.0)
|
||||
cp $kernel/modules.* lib/modules/0.0
|
||||
depmod -b . 0.0
|
||||
|
||||
(for i in ${lib.concatStringsSep " " targets}; do
|
||||
modprobe -S 0.0 -d $NIX_BUILD_TOP --show-depends $i | sed "s,^insmod $NIX_BUILD_TOP/lib/modules/0.0/,,g"
|
||||
done) | awk '!a[$0]++' > load-order
|
||||
(for i in ${lib.concatStringsSep " " targets}; do
|
||||
modprobe -S 0.0 -d $NIX_BUILD_TOP --show-depends $i | sed "s,^insmod $NIX_BUILD_TOP/lib/modules/0.0/,,g"
|
||||
done) | awk '!a[$0]++' > load-order
|
||||
|
||||
mkdir $out
|
||||
for i in $(cat load-order); do
|
||||
install -v $NIX_BUILD_TOP/lib/modules/0.0/$i -D $out/$i
|
||||
done
|
||||
echo "O=$out" > $out/load.sh
|
||||
sed "s,^,insmod \$O/,g" < load-order >> $out/load.sh
|
||||
echo "O=$out" > $out/unload.sh
|
||||
tac load-order | sed "s,^,rmmod \$O/,g" > $out/unload.sh
|
||||
'';
|
||||
in oneshot {
|
||||
name = "kmodloader-" + (concatStringsSep "-" targets);
|
||||
mkdir $out
|
||||
for i in $(cat load-order); do
|
||||
install -v $NIX_BUILD_TOP/lib/modules/0.0/$i -D $out/$i
|
||||
done
|
||||
echo "O=$out" > $out/load.sh
|
||||
sed "s,^,insmod \$O/,g" < load-order >> $out/load.sh
|
||||
echo "O=$out" > $out/unload.sh
|
||||
tac load-order | sed "s,^,rmmod \$O/,g" > $out/unload.sh
|
||||
'';
|
||||
in
|
||||
oneshot {
|
||||
name = "kmodloader-" + (concatStringsSep "-" targets);
|
||||
up = "sh ${loader}/load.sh";
|
||||
down = "sh ${loader}/unload.sh";
|
||||
inherit dependencies;
|
||||
|
@@ -25,49 +25,67 @@ let
|
||||
fdmove -c 2 1
|
||||
emptyenv chroot . /bin/init
|
||||
'';
|
||||
base = {...} : {
|
||||
config = {
|
||||
services = {
|
||||
banner = oneshot {
|
||||
name = "banner";
|
||||
up = "cat /etc/banner > /dev/console";
|
||||
down = "true";
|
||||
base =
|
||||
{ ... }:
|
||||
{
|
||||
config = {
|
||||
services = {
|
||||
banner = oneshot {
|
||||
name = "banner";
|
||||
up = "cat /etc/banner > /dev/console";
|
||||
down = "true";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
filesystem = dir {
|
||||
exec = symlink doChroot;
|
||||
etc = dir {
|
||||
banner = symlink (pkgs.writeText "banner" ''
|
||||
filesystem = dir {
|
||||
exec = symlink doChroot;
|
||||
etc = dir {
|
||||
banner = symlink (
|
||||
pkgs.writeText "banner" ''
|
||||
|
||||
LADIES AND GENTLEMEN WE ARE FLOATING IN SPACE
|
||||
LADIES AND GENTLEMEN WE ARE FLOATING IN SPACE
|
||||
|
||||
Most services are disabled. The system is operating
|
||||
with a ram-based root filesystem, making it safe to
|
||||
overwrite the flash devices in order to perform
|
||||
upgrades and maintenance.
|
||||
Most services are disabled. The system is operating
|
||||
with a ram-based root filesystem, making it safe to
|
||||
overwrite the flash devices in order to perform
|
||||
upgrades and maintenance.
|
||||
|
||||
Don't forget to reboot when you have finished.
|
||||
Don't forget to reboot when you have finished.
|
||||
|
||||
'');
|
||||
''
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
eval = lib.evalModules {
|
||||
modules = [
|
||||
{ _module.args = { inherit pkgs; inherit (pkgs) lim; }; }
|
||||
{
|
||||
_module.args = {
|
||||
inherit pkgs;
|
||||
inherit (pkgs) lim;
|
||||
};
|
||||
}
|
||||
../../modules/base.nix
|
||||
../../modules/users.nix
|
||||
../../modules/busybox.nix
|
||||
base
|
||||
({ ... } : paramConfig)
|
||||
({ ... } : { config = { logging.script = "t"; }; })
|
||||
({ ... }: paramConfig)
|
||||
(
|
||||
{ ... }:
|
||||
{
|
||||
config = {
|
||||
logging.script = "t";
|
||||
};
|
||||
}
|
||||
)
|
||||
../../modules/s6
|
||||
];
|
||||
};
|
||||
in systemconfig eval.config.filesystem.contents;
|
||||
in writeScriptBin "levitate" ''
|
||||
in
|
||||
systemconfig eval.config.filesystem.contents;
|
||||
in
|
||||
writeScriptBin "levitate" ''
|
||||
#!/bin/sh
|
||||
destdir=${newRoot}
|
||||
mkdir -p $destdir $destdir/nix/store
|
||||
|
@@ -13,6 +13,9 @@ stdenv.mkDerivation {
|
||||
rev = "3f4d15e36ceb58085b08dd13f3f2788e9299877b"; # v0.3.5
|
||||
hash = "sha256-i7gUb1A6FTOBCpympQpndhOG9pCDA4P0iH7ZNBqo+PA=";
|
||||
};
|
||||
buildInputs = [ zlib libyaml ];
|
||||
buildInputs = [
|
||||
zlib
|
||||
libyaml
|
||||
];
|
||||
nativeBuildInputs = [ cmake ];
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
{ buildPackages
|
||||
, callPackage
|
||||
, pseudofile
|
||||
, runCommand
|
||||
, writeText
|
||||
} : filesystem :
|
||||
{
|
||||
buildPackages,
|
||||
callPackage,
|
||||
pseudofile,
|
||||
runCommand,
|
||||
writeText,
|
||||
}:
|
||||
filesystem:
|
||||
let
|
||||
pseudofiles = pseudofile.write "files.pf" filesystem;
|
||||
|
||||
@@ -14,12 +16,18 @@ let
|
||||
# the pseudofile will give us all the needed packages
|
||||
storeContents = [ pseudofiles ];
|
||||
};
|
||||
in runCommand "frob-squashfs" {
|
||||
nativeBuildInputs = with buildPackages; [ squashfsTools qprint ];
|
||||
} ''
|
||||
in
|
||||
runCommand "frob-squashfs"
|
||||
{
|
||||
nativeBuildInputs = with buildPackages; [
|
||||
squashfsTools
|
||||
qprint
|
||||
];
|
||||
}
|
||||
''
|
||||
cp ${storefs} ./store.img
|
||||
chmod +w store.img
|
||||
mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
|
||||
mksquashfs - store.img -exit-on-error -no-recovery -quiet -no-progress -root-becomes nix -p "/ d 0755 0 0" -pf ${pseudofiles}
|
||||
cp store.img $out
|
||||
''
|
||||
''
|
||||
|
@@ -1,9 +1,9 @@
|
||||
{
|
||||
ifwait
|
||||
, serviceFns
|
||||
ifwait,
|
||||
serviceFns,
|
||||
}:
|
||||
{
|
||||
ifup = name : ifname : ''
|
||||
ifup = name: ifname: ''
|
||||
. ${serviceFns}
|
||||
${ifwait}/bin/ifwait -v ${ifname} present
|
||||
ip link set up dev ${ifname}
|
||||
|
@@ -1,100 +1,135 @@
|
||||
{
|
||||
stdenvNoCC
|
||||
, s6
|
||||
, lib
|
||||
, writeScript
|
||||
, serviceFns
|
||||
stdenvNoCC,
|
||||
s6,
|
||||
lib,
|
||||
writeScript,
|
||||
serviceFns,
|
||||
}:
|
||||
let
|
||||
prefix = "/run/services/outputs";
|
||||
output = service: name: "${prefix}/${service.name}/${name}";
|
||||
serviceScript = commands : ''
|
||||
serviceScript = commands: ''
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
. ${serviceFns}
|
||||
${commands}
|
||||
'';
|
||||
cleanupScript = name : cmds : ''
|
||||
cleanupScript = name: cmds: ''
|
||||
#!/bin/sh
|
||||
${if cmds != null then cmds else ""}
|
||||
if test -d ${prefix}/${name} ; then rm -rf ${prefix}/${name} ; fi
|
||||
'';
|
||||
service = {
|
||||
name
|
||||
, serviceType
|
||||
, run ? null
|
||||
, up ? null
|
||||
, down ? null
|
||||
, finish ? null
|
||||
, notification-fd ? null
|
||||
, producer-for ? null
|
||||
, consumer-for ? null
|
||||
, pipeline-name ? null
|
||||
, timeout-up ? 30000 # milliseconds
|
||||
, timeout-down ? 0
|
||||
, dependencies ? []
|
||||
, contents ? []
|
||||
, buildInputs ? []
|
||||
, restart-on-upgrade ? false
|
||||
, controller ? null
|
||||
}:
|
||||
service =
|
||||
{
|
||||
name,
|
||||
serviceType,
|
||||
run ? null,
|
||||
up ? null,
|
||||
down ? null,
|
||||
finish ? null,
|
||||
notification-fd ? null,
|
||||
producer-for ? null,
|
||||
consumer-for ? null,
|
||||
pipeline-name ? null,
|
||||
timeout-up ? 30000, # milliseconds
|
||||
timeout-down ? 0,
|
||||
dependencies ? [ ],
|
||||
contents ? [ ],
|
||||
buildInputs ? [ ],
|
||||
restart-on-upgrade ? false,
|
||||
controller ? null,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
# we use stdenvNoCC to avoid generating derivations with names
|
||||
# like foo.service-mips-linux-musl
|
||||
inherit name serviceType up down run finish notification-fd
|
||||
producer-for consumer-for pipeline-name timeout-up timeout-down
|
||||
restart-on-upgrade;
|
||||
buildInputs = buildInputs ++ dependencies ++ contents ++ lib.optional (controller != null) controller;
|
||||
inherit
|
||||
name
|
||||
serviceType
|
||||
up
|
||||
down
|
||||
run
|
||||
finish
|
||||
notification-fd
|
||||
producer-for
|
||||
consumer-for
|
||||
pipeline-name
|
||||
timeout-up
|
||||
timeout-down
|
||||
restart-on-upgrade
|
||||
;
|
||||
buildInputs =
|
||||
buildInputs ++ dependencies ++ contents ++ lib.optional (controller != null) controller;
|
||||
inherit controller dependencies contents;
|
||||
builder = ./builder.sh;
|
||||
};
|
||||
|
||||
longrun = {
|
||||
name
|
||||
, run
|
||||
, finish ? null
|
||||
, notification-fd ? null
|
||||
, buildInputs ? []
|
||||
, producer-for ? null
|
||||
, ...
|
||||
} @ args:
|
||||
let logger = service {
|
||||
serviceType = "longrun";
|
||||
name = "${name}-log";
|
||||
run = serviceScript "${s6}/bin/s6-log -d 10 -- p${name} 1";
|
||||
notification-fd = 10;
|
||||
consumer-for = name;
|
||||
pipeline-name = "${name}-pipeline";
|
||||
};
|
||||
in service (args // {
|
||||
buildInputs = buildInputs ++ lib.optional (producer-for == null) logger;
|
||||
serviceType = "longrun";
|
||||
run = serviceScript run;
|
||||
finish = cleanupScript name finish;
|
||||
producer-for = if producer-for != null then producer-for else "${name}-log";
|
||||
});
|
||||
longrun =
|
||||
{
|
||||
name,
|
||||
run,
|
||||
finish ? null,
|
||||
notification-fd ? null,
|
||||
buildInputs ? [ ],
|
||||
producer-for ? null,
|
||||
...
|
||||
}@args:
|
||||
let
|
||||
logger = service {
|
||||
serviceType = "longrun";
|
||||
name = "${name}-log";
|
||||
run = serviceScript "${s6}/bin/s6-log -d 10 -- p${name} 1";
|
||||
notification-fd = 10;
|
||||
consumer-for = name;
|
||||
pipeline-name = "${name}-pipeline";
|
||||
};
|
||||
in
|
||||
service (
|
||||
args
|
||||
// {
|
||||
buildInputs = buildInputs ++ lib.optional (producer-for == null) logger;
|
||||
serviceType = "longrun";
|
||||
run = serviceScript run;
|
||||
finish = cleanupScript name finish;
|
||||
producer-for = if producer-for != null then producer-for else "${name}-log";
|
||||
}
|
||||
);
|
||||
|
||||
oneshot = {
|
||||
name
|
||||
, up
|
||||
, down ? ""
|
||||
, ...
|
||||
} @ args : service (args // {
|
||||
serviceType = "oneshot";
|
||||
up = writeScript "${name}-up" (serviceScript up);
|
||||
down = writeScript
|
||||
"${name}-down"
|
||||
"${serviceScript down}\n${cleanupScript name null}";
|
||||
});
|
||||
bundle = { contents ? []
|
||||
, dependencies ? []
|
||||
, ...
|
||||
} @ args: service (args // {
|
||||
serviceType = "bundle";
|
||||
inherit contents dependencies;
|
||||
});
|
||||
oneshot =
|
||||
{
|
||||
name,
|
||||
up,
|
||||
down ? "",
|
||||
...
|
||||
}@args:
|
||||
service (
|
||||
args
|
||||
// {
|
||||
serviceType = "oneshot";
|
||||
up = writeScript "${name}-up" (serviceScript up);
|
||||
down = writeScript "${name}-down" "${serviceScript down}\n${cleanupScript name null}";
|
||||
}
|
||||
);
|
||||
bundle =
|
||||
{
|
||||
contents ? [ ],
|
||||
dependencies ? [ ],
|
||||
...
|
||||
}@args:
|
||||
service (
|
||||
args
|
||||
// {
|
||||
serviceType = "bundle";
|
||||
inherit contents dependencies;
|
||||
}
|
||||
);
|
||||
target = bundle;
|
||||
in {
|
||||
inherit target bundle oneshot output;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
target
|
||||
bundle
|
||||
oneshot
|
||||
output
|
||||
;
|
||||
longrun = lib.makeOverridable longrun;
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
{ lua, fetchFromGitHub }:
|
||||
let pname = "linotify";
|
||||
in lua.pkgs.buildLuaPackage {
|
||||
let
|
||||
pname = "linotify";
|
||||
in
|
||||
lua.pkgs.buildLuaPackage {
|
||||
inherit pname;
|
||||
version = "0.5";
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "logshipper";
|
||||
|
@@ -7,15 +7,21 @@ let
|
||||
rev = "1d4c962aad9cbe01c05df741b91e8b39c356362c";
|
||||
hash = "sha256-+Ys4sERG+TI8nRzG38UP+KqbH0efspaX0j4IHCt56RI=";
|
||||
};
|
||||
in lua.pkgs.buildLuaPackage {
|
||||
in
|
||||
lua.pkgs.buildLuaPackage {
|
||||
inherit pname;
|
||||
version = "0.1"; # :shrug:
|
||||
version = "0.1"; # :shrug:
|
||||
|
||||
inherit src;
|
||||
postPatch = ''
|
||||
sed -i -e '/strip/d' Makefile
|
||||
'';
|
||||
makeFlags = [ "LUADIR=." "CC:=$(CC)" "STRIP=true" "lualinux.so" ];
|
||||
makeFlags = [
|
||||
"LUADIR=."
|
||||
"CC:=$(CC)"
|
||||
"STRIP=true"
|
||||
"lualinux.so"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/lib/lua/${lua.luaversion}"
|
||||
|
@@ -2,7 +2,10 @@
|
||||
stdenv.mkDerivation {
|
||||
pname = "lzma";
|
||||
version = "4.32.7";
|
||||
configureFlags = [ "--enable-static" "--disable-shared"];
|
||||
configureFlags = [
|
||||
"--enable-static"
|
||||
"--disable-shared"
|
||||
];
|
||||
src = fetchurl {
|
||||
url = "https://tukaani.org/lzma/lzma-4.32.7.tar.gz";
|
||||
sha256 = "0b03bdvm388kwlcz97aflpr3ir1zpa3m0bq3s6cd3pp5a667lcwz";
|
||||
|
@@ -53,7 +53,8 @@ let
|
||||
RT2800SOC = "m";
|
||||
RT2X00 = "m";
|
||||
};
|
||||
mt7603e.kconfig = { # XXX find a better name for this
|
||||
mt7603e.kconfig = {
|
||||
# XXX find a better name for this
|
||||
WLAN_VENDOR_RALINK = "y";
|
||||
WLAN_VENDOR_MEDIATEK = "y";
|
||||
MT7603E = "y";
|
||||
@@ -70,32 +71,36 @@ let
|
||||
MAC80211_HWSIM = "y";
|
||||
};
|
||||
};
|
||||
kconfig = (foldl (config: d: (config // configs.${d}.kconfig)) {
|
||||
WLAN = "y";
|
||||
CFG80211 = "m";
|
||||
MAC80211 = "m";
|
||||
kconfig =
|
||||
(foldl (config: d: (config // configs.${d}.kconfig)) {
|
||||
WLAN = "y";
|
||||
CFG80211 = "m";
|
||||
MAC80211 = "m";
|
||||
|
||||
# (nixwrt comment) I am reluctant to have to enable this but
|
||||
# can't transmit on 5GHz bands without it (they are all marked
|
||||
# NO-IR)
|
||||
CFG80211_CERTIFICATION_ONUS = "y";
|
||||
# (nixwrt comment) can't get signed regdb to work rn, it just
|
||||
# gives me "loaded regulatory.db is malformed or signature is
|
||||
# missing/invalid"
|
||||
CFG80211_REQUIRE_SIGNED_REGDB = "n"; # depends on ONUS
|
||||
# (nixwrt comment) I am reluctant to have to enable this but
|
||||
# can't transmit on 5GHz bands without it (they are all marked
|
||||
# NO-IR)
|
||||
CFG80211_CERTIFICATION_ONUS = "y";
|
||||
# (nixwrt comment) can't get signed regdb to work rn, it just
|
||||
# gives me "loaded regulatory.db is malformed or signature is
|
||||
# missing/invalid"
|
||||
CFG80211_REQUIRE_SIGNED_REGDB = "n"; # depends on ONUS
|
||||
|
||||
CFG80211_CRDA_SUPPORT = "n";
|
||||
CFG80211_CRDA_SUPPORT = "n";
|
||||
|
||||
MAC80211_MESH = "y";
|
||||
} drivers) // extraConfig;
|
||||
MAC80211_MESH = "y";
|
||||
} drivers)
|
||||
// extraConfig;
|
||||
|
||||
writeConfig = name : config: writeText name
|
||||
(builtins.concatStringsSep
|
||||
"\n"
|
||||
(lib.mapAttrsToList
|
||||
(name: value: (if value == "n" then "# CPTCFG_${name} is not set" else "CPTCFG_${name}=${value}"))
|
||||
config
|
||||
));
|
||||
writeConfig =
|
||||
name: config:
|
||||
writeText name (
|
||||
builtins.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (
|
||||
name: value: (if value == "n" then "# CPTCFG_${name} is not set" else "CPTCFG_${name}=${value}")
|
||||
) config
|
||||
)
|
||||
);
|
||||
kconfigFile = writeConfig "backports_kconfig" kconfig;
|
||||
src = kernel-backport;
|
||||
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
|
||||
@@ -104,12 +109,19 @@ let
|
||||
name = "mac80211";
|
||||
inherit src;
|
||||
|
||||
hardeningDisable = ["all"];
|
||||
nativeBuildInputs = [buildPackages.stdenv.cc] ++
|
||||
(with buildPackages.pkgs;
|
||||
[bc bison flex pkg-config openssl
|
||||
which kmod cpio
|
||||
]);
|
||||
hardeningDisable = [ "all" ];
|
||||
nativeBuildInputs =
|
||||
[ buildPackages.stdenv.cc ]
|
||||
++ (with buildPackages.pkgs; [
|
||||
bc
|
||||
bison
|
||||
flex
|
||||
pkg-config
|
||||
openssl
|
||||
which
|
||||
kmod
|
||||
cpio
|
||||
]);
|
||||
inherit CC CROSS_COMPILE;
|
||||
ARCH = arch;
|
||||
dontStrip = true;
|
||||
@@ -166,18 +178,27 @@ let
|
||||
find . -name \*.ko | cpio --make-directories -p $out/lib/modules/0.0
|
||||
depmod -b $out -v 0.0
|
||||
touch $out/load.sh
|
||||
for i in ${lib.concatStringsSep " "
|
||||
(map
|
||||
(d: let c = { module = d; } // configs.${d} ;
|
||||
in c.module)
|
||||
drivers)}; do
|
||||
for i in ${
|
||||
lib.concatStringsSep " " (
|
||||
map (
|
||||
d:
|
||||
let
|
||||
c = {
|
||||
module = d;
|
||||
} // configs.${d};
|
||||
in
|
||||
c.module
|
||||
) drivers
|
||||
)
|
||||
}; do
|
||||
modprobe -S 0.0 -d $out --show-depends $i >> $out/load.sh
|
||||
done
|
||||
tac < $out/load.sh | sed 's/^insmod/rmmod/g' > $out/unload.sh
|
||||
'';
|
||||
};
|
||||
in oneshot {
|
||||
name = "wlan.module";
|
||||
up = "sh ${module}/load.sh";
|
||||
down = "sh ${module}/unload.sh";
|
||||
}
|
||||
in
|
||||
oneshot {
|
||||
name = "wlan.module";
|
||||
up = "sh ${module}/load.sh";
|
||||
down = "sh ${module}/unload.sh";
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
{
|
||||
stdenv
|
||||
}: stdenv.mkDerivation {
|
||||
stdenv,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "min-collect-garbage";
|
||||
buildInputs = [ ];
|
||||
src = ./.;
|
||||
|
@@ -7,7 +7,11 @@
|
||||
stdenv.mkDerivation {
|
||||
name = "min-copy-closure";
|
||||
buildInputs = [ ];
|
||||
propagatedBuildInputs = [ cpio openssh nix ];
|
||||
propagatedBuildInputs = [
|
||||
cpio
|
||||
openssh
|
||||
nix
|
||||
];
|
||||
src = ./.;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
@@ -7,12 +7,16 @@ let
|
||||
rev = "46e0470ff88c68f3a873dedbcf1dc351f4916b1a";
|
||||
hash = "sha256-uTV5gpfEMvHMBgdu41Gy2uizc3K9bXtO5BiCY70cYUs=";
|
||||
};
|
||||
in lua.pkgs.buildLuaPackage {
|
||||
in
|
||||
lua.pkgs.buildLuaPackage {
|
||||
inherit pname;
|
||||
version = "0.1"; # :shrug:
|
||||
version = "0.1"; # :shrug:
|
||||
|
||||
inherit src;
|
||||
makeFlags = [ "LUADIR=." "minisock.so" ];
|
||||
makeFlags = [
|
||||
"LUADIR=."
|
||||
"minisock.so"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/lib/lua/${lua.luaversion}"
|
||||
|
@@ -1,7 +1,9 @@
|
||||
{ lua, stdenv }:
|
||||
|
||||
let pname = "nellie";
|
||||
in lua.pkgs.buildLuaPackage {
|
||||
let
|
||||
pname = "nellie";
|
||||
in
|
||||
lua.pkgs.buildLuaPackage {
|
||||
inherit pname;
|
||||
version = "0.1.1-1";
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
{ lua, fetchFromGitHub, libmnl }:
|
||||
let pname = "netlink";
|
||||
in lua.pkgs.buildLuaPackage {
|
||||
{
|
||||
lua,
|
||||
fetchFromGitHub,
|
||||
libmnl,
|
||||
}:
|
||||
let
|
||||
pname = "netlink";
|
||||
in
|
||||
lua.pkgs.buildLuaPackage {
|
||||
inherit pname;
|
||||
version = "0.1.1-1";
|
||||
|
||||
|
@@ -6,14 +6,14 @@
|
||||
# essential for making the package cross-compilable
|
||||
|
||||
{
|
||||
stdenv
|
||||
, openssl
|
||||
, fetchzip
|
||||
, fetchpatch
|
||||
, pcre
|
||||
, zlib
|
||||
, lib
|
||||
, options ? []
|
||||
stdenv,
|
||||
openssl,
|
||||
fetchzip,
|
||||
fetchpatch,
|
||||
pcre,
|
||||
zlib,
|
||||
lib,
|
||||
options ? [ ],
|
||||
}:
|
||||
let
|
||||
# nginx configure script does not accept a with-foo_module flag for
|
||||
@@ -81,21 +81,24 @@ let
|
||||
withouts = lib.subtractLists options defaultEnabled;
|
||||
withs = lib.subtractLists defaultEnabled options;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "nginx-small";
|
||||
version = "";
|
||||
buildInputs = [ openssl pcre zlib ];
|
||||
version = "";
|
||||
buildInputs = [
|
||||
openssl
|
||||
pcre
|
||||
zlib
|
||||
];
|
||||
configureFlags =
|
||||
(map (f: "--with-${f}") withs)
|
||||
++ (map (f: "--without-${f}") withouts)
|
||||
++ lib.optional (pcre == null)
|
||||
"--without-http_rewrite_module"
|
||||
++ lib.optional (zlib == null)
|
||||
"--without-http_gzip_module";
|
||||
++ lib.optional (pcre == null) "--without-http_rewrite_module"
|
||||
++ lib.optional (zlib == null) "--without-http_gzip_module";
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-Wno-error=cpp"; # musl
|
||||
|
||||
configurePlatforms = [];
|
||||
configurePlatforms = [ ];
|
||||
patches = [
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/102-sizeof_test_fix.patch";
|
||||
|
@@ -3,6 +3,9 @@
|
||||
anoia,
|
||||
lualinux,
|
||||
}:
|
||||
writeFennel "odhcpc-script" {
|
||||
packages = [anoia lualinux];
|
||||
writeFennel "odhcpc-script" {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
];
|
||||
} ./odhcp6-script.fnl
|
||||
|
@@ -1,4 +1,8 @@
|
||||
{ fetchFromGitHub, pkgsBuildBuild, lib }:
|
||||
{
|
||||
fetchFromGitHub,
|
||||
pkgsBuildBuild,
|
||||
lib,
|
||||
}:
|
||||
let
|
||||
src = fetchFromGitHub {
|
||||
name = "openwrt-source";
|
||||
@@ -27,7 +31,8 @@ let
|
||||
${./make-mtdsplit-jffs2-endian-agnostic.patch} \
|
||||
${./fix-mtk-wed-bm-desc-ptr.patch}
|
||||
'';
|
||||
in {
|
||||
in
|
||||
{
|
||||
inherit src;
|
||||
|
||||
# The kernel sources typically used with this version of openwrt
|
||||
|
@@ -27,7 +27,8 @@ let
|
||||
patches ${src}/target/linux/${family}/patches-5.15/*.patch
|
||||
patches ${./make-mtdsplit-jffs2-endian-agnostic.patch}
|
||||
'';
|
||||
in {
|
||||
in
|
||||
{
|
||||
inherit src;
|
||||
|
||||
# The kernel sources typically used with this version of openwrt
|
||||
|
@@ -7,25 +7,29 @@
|
||||
anoia,
|
||||
linotify,
|
||||
lualinux,
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "output-template";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "output-template";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [lua];
|
||||
buildInputs = [ lua ];
|
||||
doCheck = true;
|
||||
|
||||
buildPhase = ''
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
] ;
|
||||
mainFunction = "run";
|
||||
} ./output-template.fnl } ${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./output-template.fnl
|
||||
} ${name}
|
||||
'';
|
||||
checkPhase = "make check";
|
||||
installPhase = ''
|
||||
|
@@ -3,8 +3,9 @@
|
||||
stdenv,
|
||||
autoreconfHook,
|
||||
substituteAll,
|
||||
}: stdenv.mkDerivation {
|
||||
pname = "ppp";
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "ppp";
|
||||
version = "2.5.0";
|
||||
nativeBuildInputs = [ autoreconfHook ];
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
with import <nixpkgs> {};
|
||||
with import <nixpkgs> { };
|
||||
mkShell {
|
||||
name = "preinit-env";
|
||||
src = ./.;
|
||||
|
@@ -1,45 +1,56 @@
|
||||
{ writeText, lib }:
|
||||
let
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
visit = prefix: attrset:
|
||||
visit =
|
||||
prefix: attrset:
|
||||
let
|
||||
qprint = msg : builtins.replaceStrings
|
||||
["\n" "=" "\"" "$" ]
|
||||
["=0A" "=3D" "=22" "=24"]
|
||||
msg;
|
||||
l =
|
||||
mapAttrsToList
|
||||
(filename: {
|
||||
type ? "f"
|
||||
, mode ? null
|
||||
, target ? null
|
||||
, contents ? null
|
||||
, file ? null
|
||||
, major ? null
|
||||
, minor ? null
|
||||
, uid ? 0
|
||||
, gid ? 0
|
||||
}:
|
||||
let
|
||||
mode' = if mode != null then mode else
|
||||
(if type == "d" then "0755" else "0644");
|
||||
pathname = "${prefix}/${filename}";
|
||||
line = "${pathname} ${type} ${mode'} ${toString uid} ${toString gid}";
|
||||
in
|
||||
if type == "f" then
|
||||
"${line} echo -n \"${qprint file}\" |qprint -d"
|
||||
else if type == "d" then
|
||||
(visit pathname contents) + "\n" + line
|
||||
else if type == "c" then "${line} ${major} ${minor}"
|
||||
else if type == "b" then "${line} ${major} ${minor}"
|
||||
else if type == "s" then "${line} ${target}"
|
||||
else if type == "l" then "${pathname} l ${target}"
|
||||
else if type == "i" then "${line} f"
|
||||
else line)
|
||||
attrset;
|
||||
in builtins.concatStringsSep "\n" l;
|
||||
in {
|
||||
write = filename : attrset : writeText filename (visit "" attrset);
|
||||
dir = contents: { type = "d"; inherit contents; };
|
||||
symlink = target: { type = "s"; inherit target; };
|
||||
qprint = msg: builtins.replaceStrings [ "\n" "=" "\"" "$" ] [ "=0A" "=3D" "=22" "=24" ] msg;
|
||||
l = mapAttrsToList (
|
||||
filename:
|
||||
{
|
||||
type ? "f",
|
||||
mode ? null,
|
||||
target ? null,
|
||||
contents ? null,
|
||||
file ? null,
|
||||
major ? null,
|
||||
minor ? null,
|
||||
uid ? 0,
|
||||
gid ? 0,
|
||||
}:
|
||||
let
|
||||
mode' = if mode != null then mode else (if type == "d" then "0755" else "0644");
|
||||
pathname = "${prefix}/${filename}";
|
||||
line = "${pathname} ${type} ${mode'} ${toString uid} ${toString gid}";
|
||||
in
|
||||
if type == "f" then
|
||||
"${line} echo -n \"${qprint file}\" |qprint -d"
|
||||
else if type == "d" then
|
||||
(visit pathname contents) + "\n" + line
|
||||
else if type == "c" then
|
||||
"${line} ${major} ${minor}"
|
||||
else if type == "b" then
|
||||
"${line} ${major} ${minor}"
|
||||
else if type == "s" then
|
||||
"${line} ${target}"
|
||||
else if type == "l" then
|
||||
"${pathname} l ${target}"
|
||||
else if type == "i" then
|
||||
"${line} f"
|
||||
else
|
||||
line
|
||||
) attrset;
|
||||
in
|
||||
builtins.concatStringsSep "\n" l;
|
||||
in
|
||||
{
|
||||
write = filename: attrset: writeText filename (visit "" attrset);
|
||||
dir = contents: {
|
||||
type = "d";
|
||||
inherit contents;
|
||||
};
|
||||
symlink = target: {
|
||||
type = "s";
|
||||
inherit target;
|
||||
};
|
||||
}
|
||||
|
@@ -24,30 +24,34 @@ let
|
||||
};
|
||||
routeros = writeShellApplication {
|
||||
name = "routeros";
|
||||
runtimeInputs = [ qemu ros-exec-script ];
|
||||
runtimeInputs = [
|
||||
qemu
|
||||
ros-exec-script
|
||||
];
|
||||
text = ''
|
||||
RUNTIME_DIRECTORY=$1
|
||||
test -d "$RUNTIME_DIRECTORY" || exit 1
|
||||
${qemu}/bin/qemu-system-x86_64 \
|
||||
-M q35 \
|
||||
-m 1024 \
|
||||
-accel kvm \
|
||||
-display none \
|
||||
-daemonize \
|
||||
-pidfile "$RUNTIME_DIRECTORY/pid" \
|
||||
-serial "unix:$RUNTIME_DIRECTORY/console,server,nowait"\
|
||||
-monitor "unix:$RUNTIME_DIRECTORY/monitor,server,nowait" \
|
||||
-snapshot -drive file=${chr-image}/chr-7.7.img,format=raw,if=virtio \
|
||||
-chardev "socket,path=$RUNTIME_DIRECTORY/qmp,server=on,wait=off,id=qga0" \
|
||||
-device virtio-serial \
|
||||
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
|
||||
-netdev socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1 \
|
||||
-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d:ea:11:02 \
|
||||
-netdev socket,id=world,mcast=230.0.0.1:1236,localaddr=127.0.0.1 \
|
||||
-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=world,mac=ba:ad:1d:ea:11:01
|
||||
ros-exec-script "$RUNTIME_DIRECTORY/qmp" ${./routeros.config}
|
||||
RUNTIME_DIRECTORY=$1
|
||||
test -d "$RUNTIME_DIRECTORY" || exit 1
|
||||
${qemu}/bin/qemu-system-x86_64 \
|
||||
-M q35 \
|
||||
-m 1024 \
|
||||
-accel kvm \
|
||||
-display none \
|
||||
-daemonize \
|
||||
-pidfile "$RUNTIME_DIRECTORY/pid" \
|
||||
-serial "unix:$RUNTIME_DIRECTORY/console,server,nowait"\
|
||||
-monitor "unix:$RUNTIME_DIRECTORY/monitor,server,nowait" \
|
||||
-snapshot -drive file=${chr-image}/chr-7.7.img,format=raw,if=virtio \
|
||||
-chardev "socket,path=$RUNTIME_DIRECTORY/qmp,server=on,wait=off,id=qga0" \
|
||||
-device virtio-serial \
|
||||
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
|
||||
-netdev socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1 \
|
||||
-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d:ea:11:02 \
|
||||
-netdev socket,id=world,mcast=230.0.0.1:1236,localaddr=127.0.0.1 \
|
||||
-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=world,mac=ba:ad:1d:ea:11:01
|
||||
ros-exec-script "$RUNTIME_DIRECTORY/qmp" ${./routeros.config}
|
||||
'';
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
inherit routeros ros-exec-script;
|
||||
}
|
||||
|
@@ -12,13 +12,18 @@
|
||||
let
|
||||
writeFennel = pkgsBuildBuild.writeFennel.override { inherit lua; };
|
||||
run-liminix-vm = writeFennel "run-liminix-vm" {
|
||||
packages = [ qemuLim lua.pkgs.luaposix fennel ];
|
||||
packages = [
|
||||
qemuLim
|
||||
lua.pkgs.luaposix
|
||||
fennel
|
||||
];
|
||||
} ./run-liminix-vm.fnl;
|
||||
connect = writeShellScript "connect-vm" ''
|
||||
export PATH="${lib.makeBinPath [ socat ]}:$PATH"
|
||||
socat -,raw,echo=0,icanon=0,isig=0,icrnl=0,escape=0x0f unix-connect:$1
|
||||
'';
|
||||
in runCommand "vm" {} ''
|
||||
in
|
||||
runCommand "vm" { } ''
|
||||
mkdir -p $out/bin
|
||||
cd $out/bin
|
||||
ln -s ${connect} ./connect-vm
|
||||
|
@@ -8,7 +8,8 @@ let
|
||||
url = "https://raw.githubusercontent.com/rxi/json.lua/11077824d7cfcd28a4b2f152518036b295e7e4ce/json.lua";
|
||||
hash = "sha256-DqzNpX+rwDMHNt4l9Fz1iYIaQrXg/gLk4xJffcC/K34=";
|
||||
};
|
||||
in runCommand "json" {} ''
|
||||
in
|
||||
runCommand "json" { } ''
|
||||
mkdir -p $out/share/lua/${lua.luaversion}/
|
||||
cp ${src} $out/share/lua/${lua.luaversion}/json.lua
|
||||
''
|
||||
|
@@ -7,17 +7,26 @@
|
||||
s6-rc,
|
||||
}:
|
||||
let
|
||||
hpr = name: arg: writeScript name ''
|
||||
#!${execline}/bin/execlineb -S0
|
||||
${s6-linux-init}/bin/s6-linux-init-hpr ${arg} \$@
|
||||
'';
|
||||
hpr =
|
||||
name: arg:
|
||||
writeScript name ''
|
||||
#!${execline}/bin/execlineb -S0
|
||||
${s6-linux-init}/bin/s6-linux-init-hpr ${arg} \$@
|
||||
'';
|
||||
init = writeScript "init" ''
|
||||
#!${execline}/bin/execlineb -S0
|
||||
${s6-linux-init}/bin/s6-linux-init -c /etc/s6-linux-init/current -m 0022 -p ${lib.makeBinPath [execline s6-linux-init s6-rc]}:/usr/bin:/bin -d /dev -- "\$@"
|
||||
${s6-linux-init}/bin/s6-linux-init -c /etc/s6-linux-init/current -m 0022 -p ${
|
||||
lib.makeBinPath [
|
||||
execline
|
||||
s6-linux-init
|
||||
s6-rc
|
||||
]
|
||||
}:/usr/bin:/bin -d /dev -- "\$@"
|
||||
'';
|
||||
in stdenvNoCC.mkDerivation {
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
name = "s6-init-bin";
|
||||
phases = ["installPhase"];
|
||||
phases = [ "installPhase" ];
|
||||
installPhase = ''
|
||||
bin=$out/bin
|
||||
mkdir -p $bin
|
||||
|
@@ -8,10 +8,12 @@
|
||||
writeText,
|
||||
services ? [ ],
|
||||
}:
|
||||
let closure-info = closureInfo { rootPaths = services; };
|
||||
in stdenvNoCC.mkDerivation {
|
||||
let
|
||||
closure-info = closureInfo { rootPaths = services; };
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
name = "s6-rc-database";
|
||||
nativeBuildInputs = [buildPackages.s6-rc];
|
||||
nativeBuildInputs = [ buildPackages.s6-rc ];
|
||||
builder = writeText "find-s6-services" ''
|
||||
source $stdenv/setup
|
||||
mkdir -p $out
|
||||
|
@@ -13,9 +13,17 @@ stdenv.mkDerivation {
|
||||
propagatedBuildInputs = [ s6-rc-up-tree ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel "s6-rc-round-robin" {
|
||||
packages = [fennel anoia linotify lualinux s6-rc-up-tree] ;
|
||||
mainFunction = "run";
|
||||
} ./robin.fnl} $out/bin/s6-rc-round-robin
|
||||
cp -p ${
|
||||
writeFennel "s6-rc-round-robin" {
|
||||
packages = [
|
||||
fennel
|
||||
anoia
|
||||
linotify
|
||||
lualinux
|
||||
s6-rc-up-tree
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./robin.fnl
|
||||
} $out/bin/s6-rc-round-robin
|
||||
'';
|
||||
}
|
||||
|
@@ -13,11 +13,15 @@ stdenv.mkDerivation {
|
||||
# propagatedBuildInputs = [ s6-rc-up-tree ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel "s6-rc-up-tree" {
|
||||
packages = [fennel
|
||||
lualinux ] ;
|
||||
mainFunction = "run";
|
||||
} ./s6-rc-up-tree.fnl } $out/bin/s6-rc-up-tree
|
||||
cp -p ${
|
||||
writeFennel "s6-rc-up-tree" {
|
||||
packages = [
|
||||
fennel
|
||||
lualinux
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./s6-rc-up-tree.fnl
|
||||
} $out/bin/s6-rc-up-tree
|
||||
'';
|
||||
postBuild = ''
|
||||
export PATH=./scripts:$PATH
|
||||
|
@@ -6,8 +6,13 @@
|
||||
util-linux-small,
|
||||
lib,
|
||||
}:
|
||||
let search_path = lib.makeBinPath [btrfs-progs util-linux-small];
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
search_path = lib.makeBinPath [
|
||||
btrfs-progs
|
||||
util-linux-small
|
||||
];
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "schnapps";
|
||||
version = "2.13.0";
|
||||
|
||||
|
@@ -1,10 +1,17 @@
|
||||
{ stdenv, buildPackages, libnl, ...} :
|
||||
let switchDotH = buildPackages.fetchurl {
|
||||
url = "https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob_plain;f=target/linux/generic/files/include/uapi/linux/switch.h;hb=99a188828713d6ff9c541590b08d4e63ef52f6d7";
|
||||
sha256 = "15kmhhcpd84y4f45rf8zai98c61jyvkc37p90pcxirna01x33wi8";
|
||||
name="switch.h";
|
||||
};
|
||||
in stdenv.mkDerivation {
|
||||
{
|
||||
stdenv,
|
||||
buildPackages,
|
||||
libnl,
|
||||
...
|
||||
}:
|
||||
let
|
||||
switchDotH = buildPackages.fetchurl {
|
||||
url = "https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob_plain;f=target/linux/generic/files/include/uapi/linux/switch.h;hb=99a188828713d6ff9c541590b08d4e63ef52f6d7";
|
||||
sha256 = "15kmhhcpd84y4f45rf8zai98c61jyvkc37p90pcxirna01x33wi8";
|
||||
name = "switch.h";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
src = buildPackages.fetchFromGitHub {
|
||||
owner = "jekader";
|
||||
repo = "swconfig";
|
||||
|
@@ -15,97 +15,104 @@
|
||||
}:
|
||||
let
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
escaped = msg : builtins.replaceStrings
|
||||
["\n" "=" "\"" "$" ]
|
||||
["\\x0a" "\\x3d" "\\x22" "\\x24"]
|
||||
msg;
|
||||
escaped =
|
||||
msg: builtins.replaceStrings [ "\n" "=" "\"" "$" ] [ "\\x0a" "\\x3d" "\\x22" "\\x24" ] msg;
|
||||
|
||||
visit = prefix: attrset:
|
||||
let makeFile = prefix : filename: {
|
||||
type ? "f"
|
||||
, mode ? null
|
||||
, target ? null
|
||||
, contents ? null
|
||||
, file ? null
|
||||
, major ? null
|
||||
, minor ? null
|
||||
, uid ? 0
|
||||
, gid ? 0
|
||||
visit =
|
||||
prefix: attrset:
|
||||
let
|
||||
makeFile =
|
||||
prefix: filename:
|
||||
{
|
||||
type ? "f",
|
||||
mode ? null,
|
||||
target ? null,
|
||||
contents ? null,
|
||||
file ? null,
|
||||
major ? null,
|
||||
minor ? null,
|
||||
uid ? 0,
|
||||
gid ? 0,
|
||||
}:
|
||||
let
|
||||
pathname = "${prefix}/${filename}";
|
||||
qpathname = builtins.toJSON pathname;
|
||||
mode' = if mode != null
|
||||
then mode
|
||||
else
|
||||
(if type == "d" then "0755" else "0644");
|
||||
cmds = {
|
||||
"f" = "PRINTFILE(${qpathname}, ${mode'}, ${builtins.toJSON (escaped file)});";
|
||||
"d" = "MKDIR(${qpathname}, ${mode'});\n" +
|
||||
(builtins.concatStringsSep "\n"
|
||||
(visit pathname contents));
|
||||
"c" = "MKNOD_C(${qpathname}, ${mode'}, ${major}, ${minor});";
|
||||
"b" = "MKNOD_B(${qpathname}, ${mode'}, ${major}, ${minor});";
|
||||
"s" = "LN_S(${builtins.toJSON target}, ${qpathname});";
|
||||
"l" = "LN(${builtins.toJSON target}, ${qpathname})";
|
||||
"i" = "MKNOD_P(${qpathname}, ${mode'});";
|
||||
};
|
||||
cmd = cmds.${type};
|
||||
chown = if uid>0 || gid>0
|
||||
then "\nCHOWN(${qpathname},${toString uid},${toString gid});\n"
|
||||
else "";
|
||||
in "unlink(${qpathname}); ${cmd} ${chown}";
|
||||
in mapAttrsToList (makeFile prefix) attrset;
|
||||
in attrset:
|
||||
let
|
||||
activateScript = writeText "activate.c" ''
|
||||
#include "defs.h"
|
||||
int main(int argc, char* argv[]) {
|
||||
chdir(argv[1]);
|
||||
${(builtins.concatStringsSep "\n" (visit "." attrset))}
|
||||
}
|
||||
'';
|
||||
in stdenv.mkDerivation {
|
||||
name="system-configuration";
|
||||
src = ./.;
|
||||
let
|
||||
pathname = "${prefix}/${filename}";
|
||||
qpathname = builtins.toJSON pathname;
|
||||
mode' = if mode != null then mode else (if type == "d" then "0755" else "0644");
|
||||
cmds = {
|
||||
"f" = "PRINTFILE(${qpathname}, ${mode'}, ${builtins.toJSON (escaped file)});";
|
||||
"d" =
|
||||
"MKDIR(${qpathname}, ${mode'});\n" + (builtins.concatStringsSep "\n" (visit pathname contents));
|
||||
"c" = "MKNOD_C(${qpathname}, ${mode'}, ${major}, ${minor});";
|
||||
"b" = "MKNOD_B(${qpathname}, ${mode'}, ${major}, ${minor});";
|
||||
"s" = "LN_S(${builtins.toJSON target}, ${qpathname});";
|
||||
"l" = "LN(${builtins.toJSON target}, ${qpathname})";
|
||||
"i" = "MKNOD_P(${qpathname}, ${mode'});";
|
||||
};
|
||||
cmd = cmds.${type};
|
||||
chown =
|
||||
if uid > 0 || gid > 0 then "\nCHOWN(${qpathname},${toString uid},${toString gid});\n" else "";
|
||||
in
|
||||
"unlink(${qpathname}); ${cmd} ${chown}";
|
||||
in
|
||||
mapAttrsToList (makeFile prefix) attrset;
|
||||
in
|
||||
attrset:
|
||||
let
|
||||
activateScript = writeText "activate.c" ''
|
||||
#include "defs.h"
|
||||
int main(int argc, char* argv[]) {
|
||||
chdir(argv[1]);
|
||||
${(builtins.concatStringsSep "\n" (visit "." attrset))}
|
||||
}
|
||||
'';
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "system-configuration";
|
||||
src = ./.;
|
||||
|
||||
CFLAGS = "-Os";
|
||||
LDFLAGS = "-static -Xlinker -static";
|
||||
CFLAGS = "-Os";
|
||||
LDFLAGS = "-static -Xlinker -static";
|
||||
|
||||
postConfigure = ''
|
||||
cp ${activateScript} activate.c
|
||||
'';
|
||||
makeFlags = ["activate"];
|
||||
installPhase = ''
|
||||
closure=${closureInfo { rootPaths = [ activateScript ]; }}
|
||||
mkdir -p $out/bin $out/etc
|
||||
cp $closure/store-paths $out/etc/nix-store-paths
|
||||
$STRIP --remove-section=.note --remove-section=.comment --strip-all activate -o $out/bin/activate
|
||||
ln -s ${s6-init-bin}/bin/init $out/bin/init
|
||||
cp -p ${writeFennel "restart-services" {} ./restart-services.fnl} $out/bin/restart-services
|
||||
cat > $out/bin/install <<EOF
|
||||
#!/bin/sh -e
|
||||
prefix=\''${1-/}
|
||||
src=\''${prefix}$out
|
||||
dest=\$prefix
|
||||
${# if we are running on a normal mounted system then
|
||||
# the actual device root is mounted on /persist
|
||||
# and /nix is bind mounted from /persist/nix
|
||||
# (see the code in preinit). So we need to check for this
|
||||
# case otherwise we will install into a ramfs/rootfs
|
||||
postConfigure = ''
|
||||
cp ${activateScript} activate.c
|
||||
'';
|
||||
makeFlags = [ "activate" ];
|
||||
installPhase = ''
|
||||
closure=${closureInfo { rootPaths = [ activateScript ]; }}
|
||||
mkdir -p $out/bin $out/etc
|
||||
cp $closure/store-paths $out/etc/nix-store-paths
|
||||
$STRIP --remove-section=.note --remove-section=.comment --strip-all activate -o $out/bin/activate
|
||||
ln -s ${s6-init-bin}/bin/init $out/bin/init
|
||||
cp -p ${writeFennel "restart-services" { } ./restart-services.fnl} $out/bin/restart-services
|
||||
cat > $out/bin/install <<EOF
|
||||
#!/bin/sh -e
|
||||
prefix=\''${1-/}
|
||||
src=\''${prefix}$out
|
||||
dest=\$prefix
|
||||
${
|
||||
# if we are running on a normal mounted system then
|
||||
# the actual device root is mounted on /persist
|
||||
# and /nix is bind mounted from /persist/nix
|
||||
# (see the code in preinit). So we need to check for this
|
||||
# case otherwise we will install into a ramfs/rootfs
|
||||
""
|
||||
}
|
||||
if test -d \$dest/persist; then dest=\$dest/persist; fi
|
||||
cp -v -fP \$src/bin/* \$src/etc/* \$dest
|
||||
${
|
||||
if attrset ? boot then
|
||||
''
|
||||
(cd \$dest
|
||||
test -d boot || mkdir boot
|
||||
cd boot
|
||||
cp ../${lib.strings.removePrefix "/" attrset.boot.target}/* .
|
||||
sync; sync
|
||||
)
|
||||
''
|
||||
else
|
||||
""
|
||||
}
|
||||
if test -d \$dest/persist; then dest=\$dest/persist; fi
|
||||
cp -v -fP \$src/bin/* \$src/etc/* \$dest
|
||||
${if attrset ? boot then ''
|
||||
(cd \$dest
|
||||
test -d boot || mkdir boot
|
||||
cd boot
|
||||
cp ../${lib.strings.removePrefix "/" attrset.boot.target}/* .
|
||||
sync; sync
|
||||
)
|
||||
'' else ""}
|
||||
EOF
|
||||
chmod +x $out/bin/install
|
||||
'';
|
||||
}
|
||||
}
|
||||
EOF
|
||||
chmod +x $out/bin/install
|
||||
'';
|
||||
}
|
||||
|
@@ -12,30 +12,40 @@
|
||||
openssl,
|
||||
rxi-json,
|
||||
makeWrapper,
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "tangc";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "tangc";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [fetch-freebsd rxi-json openssl lua jose];
|
||||
buildInputs = [
|
||||
fetch-freebsd
|
||||
rxi-json
|
||||
openssl
|
||||
lua
|
||||
jose
|
||||
];
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
buildPhase = "";
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
fetch-freebsd
|
||||
rxi-json
|
||||
fennel
|
||||
anoia
|
||||
lualinux
|
||||
jose
|
||||
] ;
|
||||
mainFunction = "run";
|
||||
} ./tangc.fnl } $out/bin/${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
fetch-freebsd
|
||||
rxi-json
|
||||
fennel
|
||||
anoia
|
||||
lualinux
|
||||
jose
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./tangc.fnl
|
||||
} $out/bin/${name}
|
||||
wrapProgram $out/bin/${name} --set JOSE_BIN ${jose}/bin/jose
|
||||
'';
|
||||
}
|
||||
|
@@ -4,13 +4,21 @@
|
||||
makeWrapper,
|
||||
}:
|
||||
let
|
||||
lua = lua5_3.withPackages (ps: with ps; [
|
||||
luasocket luaposix fennel
|
||||
]);
|
||||
in stdenv.mkDerivation {
|
||||
lua = lua5_3.withPackages (
|
||||
ps: with ps; [
|
||||
luasocket
|
||||
luaposix
|
||||
fennel
|
||||
]
|
||||
);
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "tufted";
|
||||
version = "1";
|
||||
phases = [ "unpackPhase" "installPhase" ];
|
||||
phases = [
|
||||
"unpackPhase"
|
||||
"installPhase"
|
||||
];
|
||||
buildInputs = [
|
||||
lua
|
||||
];
|
||||
|
@@ -15,10 +15,18 @@ stdenv.mkDerivation {
|
||||
propagatedBuildInputs = [ s6-rc-up-tree ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennel "uevent-watch" {
|
||||
packages = [fennel anoia nellie lualinux s6-rc-up-tree] ;
|
||||
mainFunction = "run";
|
||||
} ./watch.fnl} $out/bin/uevent-watch
|
||||
cp -p ${
|
||||
writeFennel "uevent-watch" {
|
||||
packages = [
|
||||
fennel
|
||||
anoia
|
||||
nellie
|
||||
lualinux
|
||||
s6-rc-up-tree
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./watch.fnl
|
||||
} $out/bin/uevent-watch
|
||||
'';
|
||||
checkPhase = ''
|
||||
fennelrepl ./test.fnl
|
||||
|
@@ -9,7 +9,8 @@
|
||||
let
|
||||
pname = "usb-modeswitch";
|
||||
version = "2.6.0";
|
||||
in stdenv.mkDerivation {
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
|
@@ -7,28 +7,32 @@
|
||||
anoia,
|
||||
linotify,
|
||||
lualinux,
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "watch-outputs";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "watch-outputs";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [lua];
|
||||
# doCheck = true;
|
||||
buildInputs = [ lua ];
|
||||
# doCheck = true;
|
||||
|
||||
buildPhase = ''
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
fennel
|
||||
] ;
|
||||
mainFunction = "run";
|
||||
} ./watch-outputs.fnl } ${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
fennel
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./watch-outputs.fnl
|
||||
} ${name}
|
||||
'';
|
||||
# checkPhase = "make check";
|
||||
# checkPhase = "make check";
|
||||
installPhase = ''
|
||||
install -D ${name} $out/bin/${name}
|
||||
'';
|
||||
|
@@ -8,30 +8,34 @@
|
||||
anoia,
|
||||
linotify,
|
||||
lualinux,
|
||||
stdenv
|
||||
stdenv,
|
||||
}:
|
||||
let name = "watch-ssh-keys";
|
||||
in stdenv.mkDerivation {
|
||||
let
|
||||
name = "watch-ssh-keys";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [lua];
|
||||
nativeBuildInputs = [fennelrepl];
|
||||
buildInputs = [ lua ];
|
||||
nativeBuildInputs = [ fennelrepl ];
|
||||
|
||||
buildPhase = ''
|
||||
fennelrepl --test ./watch-ssh-keys.fnl
|
||||
cp -p ${writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
fennel
|
||||
];
|
||||
macros = [
|
||||
anoia.dev
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./watch-ssh-keys.fnl } ${name}
|
||||
cp -p ${
|
||||
writeFennel name {
|
||||
packages = [
|
||||
anoia
|
||||
lualinux
|
||||
linotify
|
||||
fennel
|
||||
];
|
||||
macros = [
|
||||
anoia.dev
|
||||
];
|
||||
mainFunction = "run";
|
||||
} ./watch-ssh-keys.fnl
|
||||
} ${name}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
@@ -1,13 +1,18 @@
|
||||
{
|
||||
writeScriptBin
|
||||
, lib
|
||||
}
|
||||
: name : { runtimeInputs ? [] } : text : writeScriptBin name ''
|
||||
#!/bin/sh
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
writeScriptBin,
|
||||
lib,
|
||||
}:
|
||||
name:
|
||||
{
|
||||
runtimeInputs ? [ ],
|
||||
}:
|
||||
text:
|
||||
writeScriptBin name ''
|
||||
#!/bin/sh
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
export PATH="${lib.makeBinPath runtimeInputs}:$PATH"
|
||||
${text}
|
||||
export PATH="${lib.makeBinPath runtimeInputs}:$PATH"
|
||||
${text}
|
||||
''
|
||||
|
@@ -18,10 +18,9 @@ let
|
||||
f: "${f}/share/lua/${lua.luaversion}/?.lua;" + "${f}/share/lua/${lua.luaversion}/?/init.lua;"
|
||||
) packages;
|
||||
luacpath = map (f: "${f}/lib/lua/${lua.luaversion}/?.so;") packages;
|
||||
macropath = concatStringsSep ";"
|
||||
(map (f: "${f}/share/lua/${lua.luaversion}/?.fnl") macros);
|
||||
macropath = concatStringsSep ";" (map (f: "${f}/share/lua/${lua.luaversion}/?.fnl") macros);
|
||||
luaFlags = lib.optionalString (mainFunction != null) "-e dofile(arg[0]).${mainFunction}()";
|
||||
quoteString = string : "'${replaceStrings ["'"] ["'\\''"] string}'";
|
||||
quoteString = string: "'${replaceStrings [ "'" ] [ "'\\''" ] string}'";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
@@ -34,7 +33,9 @@ stdenv.mkDerivation {
|
||||
echo "package.cpath = ${quoteString (concatStringsSep "" luacpath)} .. package.cpath"
|
||||
echo "local ok, stdlib = pcall(require,'posix.stdlib'); if ok then stdlib.setenv('PATH',${quoteString (lib.makeBinPath packages)} .. \":\" .. os.getenv('PATH')) end"
|
||||
echo "local ok, ll = pcall(require,'lualinux'); if ok then ll.setenv('PATH',${quoteString (lib.makeBinPath packages)} .. \":\" .. os.getenv('PATH')) end"
|
||||
fennel ${if macropath != "" then "--add-macro-path ${quoteString macropath}" else ""} ${if correlate then "--correlate" else ""} --compile ${source}
|
||||
fennel ${if macropath != "" then "--add-macro-path ${quoteString macropath}" else ""} ${
|
||||
if correlate then "--correlate" else ""
|
||||
} --compile ${source}
|
||||
) > ${name}.lua
|
||||
|
||||
'';
|
||||
|
Reference in New Issue
Block a user