modules: move options to the top
This greatly improves readability and makes it easier to discover options.
This commit was genereated by running the following script inside the
repo root dir:
#!/usr/bin/env ruby
def transform(src)
return false if src.include?('inherit options;')
success = false
options = nil
src.sub!(/^ options.*?^ }.*?;/m) do |match|
options = match
" inherit options;"
end
return false if !options
src.sub!(/^with lib;\s*let\n+/m) do |match|
success = true
<<~EOF
with lib;
let
#{options}
EOF
end
success
end
Dir['modules/**/*.nix'].each do |f|
src = File.read(f)
if transform(src)
puts "Changed file #{f}"
File.write(f, src)
end
end
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.hardware-wallets;
|
||||
dataDir = "/var/lib/hardware-wallets/";
|
||||
enabled = cfg.ledger || cfg.trezor;
|
||||
in {
|
||||
options.services.hardware-wallets = {
|
||||
ledger = mkOption {
|
||||
type = types.bool;
|
||||
@@ -31,6 +26,12 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.services.hardware-wallets;
|
||||
dataDir = "/var/lib/hardware-wallets/";
|
||||
enabled = cfg.ledger || cfg.trezor;
|
||||
in {
|
||||
inherit options;
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf (cfg.ledger || cfg.trezor) {
|
||||
assertions = [
|
||||
|
||||
Reference in New Issue
Block a user