123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- {
- inputs = {
- nixpkgs.url = "nixpkgs/nixos-unstable";
- nixos-generators = {
- url = "github:nix-community/nixos-generators";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- };
- outputs = { self, nixpkgs, nixos-generators, ... }: {
- packages.x86_64-linux = {
- qcow2 = nixos-generators.nixosGenerate {
- system = "x86_64-linux";
- modules = [
- ({config, lib, modulesPath, pkgs, ...}: {
- virtualisation.docker.enable = true;
- environment.systemPackages = with pkgs; [
- docker-compose
- bash
- sudo
- coreutils
- ];
- systemd.services.my-docker-compose = {
- script = ''
- ${pkgs.coreutils}/bin/chmod -R 0777 /data
- ${pkgs.docker-compose}/bin/docker-compose -f /data/docker-compose.yml up
- '';
- wantedBy = ["multi-user.target"];
- # If you use podman
- #after = ["podman.service" "podman.socket"];
- # If you use docker
- after = ["docker.service" "docker.socket"];
- requires = ["docker.service" "docker.socket"];
- };
- system.build.qcow = lib.mkForce (import "${toString modulesPath}/../lib/make-disk-image.nix" {
- inherit lib config pkgs;
- diskSize = 30720;
- format = "qcow2";
- partitionTableType = "hybrid";
- contents = [
- {source = ./.; target = "/data";}
- ];
- });
- services.openssh = {
- enable = true;
- settings = {
- # require public key authentication for better security
- PasswordAuthentication = false;
- KbdInteractiveAuthentication = false;
- PermitRootLogin = "yes";
- };
- };
- users.users."root".openssh.authorizedKeys.keyFiles = [
- ./ssh/generated.pub
- ];
- system.stateVersion = "23.11";
- })
- ];
- format = "qcow";
- };
- };
- };
- }
|