style: reformat with nixfmt-rfc-style
This commit is contained in:
parent
5ad8bc1d56
commit
1c5d83d81e
99 changed files with 2247 additions and 1334 deletions
|
@ -1,7 +1,21 @@
|
|||
name:
|
||||
{ user ? { }, hm ? { }, modules ? [ ], config, usesContainers ? false, ... }:
|
||||
{
|
||||
user ? { },
|
||||
hm ? { },
|
||||
modules ? [ ],
|
||||
config,
|
||||
usesContainers ? false,
|
||||
...
|
||||
}:
|
||||
|
||||
{ inputs, pkgs, lib, home-manager, ... }: {
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
home-manager,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [ home-manager.nixosModules.home-manager ];
|
||||
|
||||
users.users."${name}" = {
|
||||
|
@ -9,21 +23,30 @@ name:
|
|||
shell = pkgs.zsh;
|
||||
|
||||
# increase sub{u,g}id range for container user namespaces
|
||||
subUidRanges = lib.optionals usesContainers [{
|
||||
startUid = 100000;
|
||||
count = 60000000;
|
||||
}];
|
||||
subGidRanges = lib.optionals usesContainers [{
|
||||
startGid = 100000;
|
||||
count = 60000000;
|
||||
}];
|
||||
subUidRanges = lib.optionals usesContainers [
|
||||
{
|
||||
startUid = 100000;
|
||||
count = 60000000;
|
||||
}
|
||||
];
|
||||
subGidRanges = lib.optionals usesContainers [
|
||||
{
|
||||
startGid = 100000;
|
||||
count = 60000000;
|
||||
}
|
||||
];
|
||||
} // user;
|
||||
|
||||
home-manager = {
|
||||
useUserPackages = true;
|
||||
useGlobalPkgs = true;
|
||||
backupFileExtension = "backup";
|
||||
users."${name}" = lib.mkMerge [ { imports = modules; } (import config) ];
|
||||
extraSpecialArgs = { inherit inputs; };
|
||||
users."${name}" = lib.mkMerge [
|
||||
{ imports = modules; }
|
||||
(import config)
|
||||
];
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
};
|
||||
} // hm;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
{ inputs, lib, ... }:
|
||||
|
||||
let createUser' = import ./createUser.nix;
|
||||
in {
|
||||
let
|
||||
createUser' = import ./createUser.nix;
|
||||
in
|
||||
{
|
||||
imports = [ ./openwrt.nix ];
|
||||
options.flake.lib = lib.mkOption { type = with lib.types; lazyAttrsOf raw; };
|
||||
config.flake.lib = {
|
||||
createSystem = hostName:
|
||||
createSystem =
|
||||
hostName:
|
||||
{ hardwareConfig, config }:
|
||||
({ pkgs, lib, ... }: {
|
||||
networking.hostName = hostName;
|
||||
(
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
networking.hostName = hostName;
|
||||
|
||||
imports = [ ../modules/common.nix hardwareConfig config ];
|
||||
});
|
||||
createUser = name: args:
|
||||
({ pkgs, ... }@args2:
|
||||
(createUser' name args) ({ inherit (inputs) home-manager; } // args2));
|
||||
imports = [
|
||||
../modules/common.nix
|
||||
hardwareConfig
|
||||
config
|
||||
];
|
||||
}
|
||||
);
|
||||
createUser =
|
||||
name: args:
|
||||
({ pkgs, ... }@args2: (createUser' name args) ({ inherit (inputs) home-manager; } // args2));
|
||||
createMediaGroup = _: { users.groups.media.gid = 600; };
|
||||
};
|
||||
}
|
||||
|
|
104
lib/openwrt.nix
104
lib/openwrt.nix
|
@ -1,60 +1,72 @@
|
|||
{ inputs, ... }:
|
||||
let
|
||||
getProfiles = pkgs:
|
||||
getProfiles =
|
||||
pkgs:
|
||||
inputs.openwrt-imagebuilder.lib.profiles {
|
||||
inherit pkgs;
|
||||
release = "snapshot";
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
flake.lib.mkOpenwrtImage =
|
||||
{ pkgs, hostname, timezone, ipaddr, packages ? [ ], uci ? "" }:
|
||||
inputs.openwrt-imagebuilder.lib.build
|
||||
((getProfiles pkgs).identifyProfile "glinet_gl-mt6000" // {
|
||||
packages = [
|
||||
# TODO does this include everything that the web firmware builder includes?
|
||||
"auc"
|
||||
"dawn"
|
||||
"luci-app-attendedsysupgrade"
|
||||
"luci-app-dawn"
|
||||
"luci-app-nextdns"
|
||||
"luci-ssl"
|
||||
"nextdns"
|
||||
"tailscale"
|
||||
] ++ packages;
|
||||
{
|
||||
pkgs,
|
||||
hostname,
|
||||
timezone,
|
||||
ipaddr,
|
||||
packages ? [ ],
|
||||
uci ? "",
|
||||
}:
|
||||
inputs.openwrt-imagebuilder.lib.build (
|
||||
(getProfiles pkgs).identifyProfile "glinet_gl-mt6000"
|
||||
// {
|
||||
packages = [
|
||||
# TODO does this include everything that the web firmware builder includes?
|
||||
"auc"
|
||||
"dawn"
|
||||
"luci-app-attendedsysupgrade"
|
||||
"luci-app-dawn"
|
||||
"luci-app-nextdns"
|
||||
"luci-ssl"
|
||||
"nextdns"
|
||||
"tailscale"
|
||||
] ++ packages;
|
||||
|
||||
files = pkgs.runCommand "image-files" { } ''
|
||||
mkdir -p $out/etc/uci-defaults
|
||||
cat > $out/etc/uci-defaults/99-custom <<EOF
|
||||
hostname='${hostname}'
|
||||
timezone='${timezone}'
|
||||
ipaddr='${ipaddr}'
|
||||
# TODO set up SSH config (register public keys, disable password login, ...)
|
||||
files = pkgs.runCommand "image-files" { } ''
|
||||
mkdir -p $out/etc/uci-defaults
|
||||
cat > $out/etc/uci-defaults/99-custom <<EOF
|
||||
hostname='${hostname}'
|
||||
timezone='${timezone}'
|
||||
ipaddr='${ipaddr}'
|
||||
|
||||
# Set system defaults
|
||||
uci set system.@system[0].hostname="$hostname"
|
||||
uci set system.@system[0].timezone="$timezone"
|
||||
uci set network.lan.ipaddr="$ipaddr"
|
||||
uci set uhttpd.main.redirect_https='1'
|
||||
${uci}
|
||||
uci commit
|
||||
/etc/init.d/system reload
|
||||
# Set system defaults
|
||||
uci set system.@system[0].hostname="$hostname"
|
||||
uci set system.@system[0].timezone="$timezone"
|
||||
uci set network.lan.ipaddr="$ipaddr"
|
||||
uci set uhttpd.main.redirect_https='1'
|
||||
${uci}
|
||||
uci commit
|
||||
/etc/init.d/system reload
|
||||
|
||||
# Set WiFi country code
|
||||
iw reg set DE
|
||||
# Set WiFi country code
|
||||
iw reg set DE
|
||||
|
||||
# Enable hardware acceleration: Hardware Flow Offloading (HFO)
|
||||
uci set firewall.@defaults[0].flow_offloading=1
|
||||
uci set firewall.@defaults[0].flow_offloading_hw=1
|
||||
uci commit
|
||||
/etc/init.d/firewall restart
|
||||
# Enable hardware acceleration: Hardware Flow Offloading (HFO)
|
||||
uci set firewall.@defaults[0].flow_offloading=1
|
||||
uci set firewall.@defaults[0].flow_offloading_hw=1
|
||||
uci commit
|
||||
/etc/init.d/firewall restart
|
||||
|
||||
# Enable hardware acceleration: Wireless Ethernet Dispatch (WED)
|
||||
echo 'options mt7915e wed_enable=Y' >>/etc/modules.conf
|
||||
# Enable hardware acceleration: Wireless Ethernet Dispatch (WED)
|
||||
echo 'options mt7915e wed_enable=Y' >>/etc/modules.conf
|
||||
|
||||
# Set up automatic upgrades
|
||||
# TODO download upgrade script from GitHub gist
|
||||
# wget [github gist url]
|
||||
# cat "0 3 * * * /path/to/gist/script" >>/etc/crontabs/root
|
||||
EOF
|
||||
'';
|
||||
});
|
||||
# Set up automatic upgrades
|
||||
# TODO download upgrade script from GitHub gist
|
||||
# wget [github gist url]
|
||||
# cat "0 3 * * * /path/to/gist/script" >>/etc/crontabs/root
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue