Skip to content

Commit fb30cf1

Browse files
DavHauLassulus
authored andcommitted
reformat all files
1 parent 121b5a7 commit fb30cf1

36 files changed

+281
-201
lines changed

configuration.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
{ config, lib, pkgs, ... }:
21
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}: {
37
services.sshd.enable = true;
48
services.nginx.enable = true;
59

6-
networking.firewall.allowedTCPPorts = [ 80 ];
7-
10+
networking.firewall.allowedTCPPorts = [80];
11+
812
users.users.root.password = "nixos";
913
services.openssh.permitRootLogin = lib.mkDefault "yes";
1014
services.getty.autologinUser = lib.mkDefault "root";

default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
(import (builtins.fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
22
src = ./.;
3-
}).defaultNix.default
3+
})
4+
.defaultNix
5+
.default

flake.nix

Lines changed: 124 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -7,110 +7,131 @@
77
# Bin dependency
88
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
99

10-
outputs = { self, nixpkgs, nixlib }:
11-
10+
outputs = {
11+
self,
12+
nixpkgs,
13+
nixlib,
14+
}:
1215
# Library modules (depend on nixlib)
13-
{
14-
# export all generator formats in ./formats
15-
nixosModules = nixlib.lib.mapAttrs' (file: _: {
16-
name = nixlib.lib.removeSuffix ".nix" file;
17-
# The exported module should include the internal format* options
18-
value.imports = [ (./formats + "/${file}") ./format-module.nix ];
19-
}) (builtins.readDir ./formats);
20-
21-
# example usage in flakes:
22-
# outputs = { self, nixpkgs, nixos-generators, ...}: {
23-
# vmware = nixos-generators.nixosGenerate {
24-
# system = "x86_64-linux";
25-
# modules = [./configuration.nix];
26-
# format = "vmware";
27-
# };
28-
# }
29-
30-
nixosGenerate = { pkgs ? null, lib ? nixpkgs.lib, format, system ? null, specialArgs ? { }, modules ? [ ], customFormats ? {} }:
31-
let
32-
extraFormats = lib.mapAttrs' (name: value: lib.nameValuePair
33-
(name)
34-
(value // {
35-
imports = ( value.imports or [] ++ [ ./format-module.nix ] );
36-
} )
37-
) customFormats;
38-
formatModule = builtins.getAttr format (self.nixosModules // extraFormats);
39-
image = nixpkgs.lib.nixosSystem {
40-
inherit pkgs specialArgs;
41-
system = if system != null then system else pkgs.system;
42-
lib = if lib != null then lib else pkgs.lib;
43-
modules = [
44-
formatModule
45-
] ++ modules;
46-
};
47-
in
48-
image.config.system.build.${image.config.formatAttr};
49-
50-
}
51-
52-
//
53-
54-
55-
# Binary and Devshell outputs (depend on nixpkgs)
56-
(
57-
let
58-
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin" ];
59-
in {
60-
61-
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
62-
63-
packages = forAllSystems (system: let
64-
pkgs = nixpkgs.legacyPackages."${system}";
65-
in rec {
66-
nixos-generators = nixpkgs.lib.warn ''
67-
68-
Deprecation note from: github:nix-community/nixos-generators
69-
70-
Was renamed:
71-
72-
Was: nixos-generators.packages.${system}.nixos-generators
73-
Now: nixos-generators.packages.${system}.nixos-generate
74-
75-
Plase adapt your references
76-
'' nixos-generate;
77-
nixos-generate = pkgs.stdenv.mkDerivation {
78-
name = "nixos-generate";
79-
src = ./.;
80-
meta.description = "Collection of image builders";
81-
nativeBuildInputs = with pkgs; [ makeWrapper ];
82-
installFlags = [ "PREFIX=$(out)" ];
83-
postFixup = ''
84-
wrapProgram $out/bin/nixos-generate \
85-
--prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ jq coreutils findutils ])}
86-
'';
87-
};
88-
});
89-
90-
defaultPackage = forAllSystems (system: self.packages."${system}".nixos-generate);
91-
92-
devShell = forAllSystems (system: let
93-
pkgs = nixpkgs.legacyPackages."${system}";
94-
in pkgs.mkShell {
95-
buildInputs = with pkgs; [ jq coreutils findutils ];
96-
});
97-
98-
# Make it runnable with `nix run`
99-
apps = forAllSystems (system: let
100-
nixos-generate = {
101-
type = "app";
102-
program = "${self.packages."${system}".nixos-generate}/bin/nixos-generate";
16+
{
17+
# export all generator formats in ./formats
18+
nixosModules = nixlib.lib.mapAttrs' (file: _: {
19+
name = nixlib.lib.removeSuffix ".nix" file;
20+
# The exported module should include the internal format* options
21+
value.imports = [(./formats + "/${file}") ./format-module.nix];
22+
}) (builtins.readDir ./formats);
23+
24+
# example usage in flakes:
25+
# outputs = { self, nixpkgs, nixos-generators, ...}: {
26+
# vmware = nixos-generators.nixosGenerate {
27+
# system = "x86_64-linux";
28+
# modules = [./configuration.nix];
29+
# format = "vmware";
30+
# };
31+
# }
32+
33+
nixosGenerate = {
34+
pkgs ? null,
35+
lib ? nixpkgs.lib,
36+
format,
37+
system ? null,
38+
specialArgs ? {},
39+
modules ? [],
40+
customFormats ? {},
41+
}: let
42+
extraFormats =
43+
lib.mapAttrs' (
44+
name: value:
45+
lib.nameValuePair
46+
name
47+
(value
48+
// {
49+
imports = (value.imports or [] ++ [./format-module.nix]);
50+
})
51+
)
52+
customFormats;
53+
formatModule = builtins.getAttr format (self.nixosModules // extraFormats);
54+
image = nixpkgs.lib.nixosSystem {
55+
inherit pkgs specialArgs;
56+
system =
57+
if system != null
58+
then system
59+
else pkgs.system;
60+
lib =
61+
if lib != null
62+
then lib
63+
else pkgs.lib;
64+
modules =
65+
[
66+
formatModule
67+
]
68+
++ modules;
10369
};
104-
in {
105-
inherit nixos-generate;
106-
107-
# Nix >= 2.7 flake output schema uses `apps.<system>.default` instead
108-
# of `defaultApp.<system>` to signify the default app (the thing that
109-
# gets run with `nix run . -- <args>`)
110-
default = nixos-generate;
111-
});
112-
113-
defaultApp = forAllSystems (system: self.apps."${system}".nixos-generate);
70+
in
71+
image.config.system.build.${image.config.formatAttr};
11472
}
115-
);
73+
//
74+
# Binary and Devshell outputs (depend on nixpkgs)
75+
(
76+
let
77+
forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin"];
78+
in {
79+
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
80+
81+
packages = forAllSystems (system: let
82+
pkgs = nixpkgs.legacyPackages."${system}";
83+
in rec {
84+
nixos-generators =
85+
nixpkgs.lib.warn ''
86+
87+
Deprecation note from: github:nix-community/nixos-generators
88+
89+
Was renamed:
90+
91+
Was: nixos-generators.packages.${system}.nixos-generators
92+
Now: nixos-generators.packages.${system}.nixos-generate
93+
94+
Plase adapt your references
95+
''
96+
nixos-generate;
97+
nixos-generate = pkgs.stdenv.mkDerivation {
98+
name = "nixos-generate";
99+
src = ./.;
100+
meta.description = "Collection of image builders";
101+
nativeBuildInputs = with pkgs; [makeWrapper];
102+
installFlags = ["PREFIX=$(out)"];
103+
postFixup = ''
104+
wrapProgram $out/bin/nixos-generate \
105+
--prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [jq coreutils findutils])}
106+
'';
107+
};
108+
});
109+
110+
defaultPackage = forAllSystems (system: self.packages."${system}".nixos-generate);
111+
112+
devShell = forAllSystems (system: let
113+
pkgs = nixpkgs.legacyPackages."${system}";
114+
in
115+
pkgs.mkShell {
116+
buildInputs = with pkgs; [jq coreutils findutils];
117+
});
118+
119+
# Make it runnable with `nix run`
120+
apps = forAllSystems (system: let
121+
nixos-generate = {
122+
type = "app";
123+
program = "${self.packages."${system}".nixos-generate}/bin/nixos-generate";
124+
};
125+
in {
126+
inherit nixos-generate;
127+
128+
# Nix >= 2.7 flake output schema uses `apps.<system>.default` instead
129+
# of `defaultApp.<system>` to signify the default app (the thing that
130+
# gets run with `nix run . -- <args>`)
131+
default = nixos-generate;
132+
});
133+
134+
defaultApp = forAllSystems (system: self.apps."${system}".nixos-generate);
135+
}
136+
);
116137
}

format-module.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, ... }: rec {
1+
{lib, ...}: rec {
22
_file = ./format-module.nix;
33
# This deliberate key makes sure this module will be deduplicated
44
# regardless of the accessor path: either via flake's nixosModule
@@ -18,4 +18,3 @@
1818
};
1919
};
2020
}
21-

formats/amazon.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{ modulesPath, ... }:
2-
{
1+
{modulesPath, ...}: {
32
imports = [
43
"${toString modulesPath}/../maintainers/scripts/ec2/amazon-image.nix"
54
];

formats/azure.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{ modulesPath, ... }:
2-
{
1+
{modulesPath, ...}: {
32
imports = [
43
"${toString modulesPath}/virtualisation/azure-image.nix"
54
];

formats/cloudstack.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
{ config, lib, pkgs, modulesPath, ... }:
21
{
2+
config,
3+
lib,
4+
pkgs,
5+
modulesPath,
6+
...
7+
}: {
38
imports = [
49
"${toString modulesPath}/virtualisation/cloudstack-config.nix"
510
];
611

7-
system.build.cloudstackImage = import "${toString modulesPath}/../lib/make-disk-image.nix" {
12+
system.build.cloudstackImage = import "${toString modulesPath}/../lib/make-disk-image.nix" {
813
inherit lib config pkgs;
914
diskSize = 8192;
1015
format = "qcow2";
11-
configFile = pkgs.writeText "configuration.nix"
16+
configFile =
17+
pkgs.writeText "configuration.nix"
1218
''
1319
{
1420
imports = [ "${toString modulesPath}/virtualisation/cloudstack-config.nix" ];

formats/do.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{ modulesPath, ... }:
2-
{
1+
{modulesPath, ...}: {
32
imports = [
43
"${toString modulesPath}/virtualisation/digital-ocean-image.nix"
54
];

formats/docker.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
{ modulesPath, lib, ... }:
21
{
2+
modulesPath,
3+
lib,
4+
...
5+
}: {
36
imports = [
47
"${toString modulesPath}/virtualisation/docker-image.nix"
58
];

formats/gce.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{ modulesPath, ... }:
2-
{
1+
{modulesPath, ...}: {
32
imports = [
43
"${toString modulesPath}/virtualisation/google-compute-image.nix"
54
];

0 commit comments

Comments
 (0)