From 1be5160b1ac7d11117aa9c79b193596ba5edfdb4 Mon Sep 17 00:00:00 2001 From: soyouzpanda Date: Sat, 30 Dec 2023 17:18:55 +0100 Subject: [PATCH] Initial commit; minimal emulationstation --- .gitignore | 2 + .gitmodules | 6 ++ Makefile | 16 +++++ configuration.nix | 37 ++++++++++++ emulationstation/configuration-files.nix | 77 ++++++++++++++++++++++++ emulationstation/roms | 1 + emulationstation/theme | 1 + flake.lock | 48 +++++++++++++++ flake.nix | 36 +++++++++++ 9 files changed, 224 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Makefile create mode 100644 configuration.nix create mode 100644 emulationstation/configuration-files.nix create mode 160000 emulationstation/roms create mode 160000 emulationstation/theme create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..839c95a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/nixos.qcow2 +/result diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..63721fa --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "emulationstation/roms"] + path = emulationstation/roms + url = ssh://git@git.soyouzpanda.fr:2222/soyouzpanda/arcade-roms.git +[submodule "emulationstation/theme"] + path = emulationstation/theme + url = git@git.dgnum.eu:ecoppens/arcade-theme.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e8d4f9a --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHNOY: run all build clean debug + +all: clean build + +run: all + ./result/bin/run-nixos-vm + +build: + nix build ".?submodules=1#nixosConfigurations.vm.config.system.build.vm" --no-eval-cache + +debug: + nix build ".#nixosConfigurations.vm.config.system.build.vm" --no-eval-cache --show-trace + +clean: + rm nixos.qcow2 -f + rm result -rf diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..48f2e97 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,37 @@ +({ config, lib, pkgs, home-manager, username, userhome, ... }: { + system.stateVersion = "23.11"; + + environment.systemPackages = [ + pkgs.xorg.xorgserver + pkgs.xorg.xinit + pkgs.xorg.xf86inputevdev + pkgs.xorg.xf86inputsynaptics + pkgs.xorg.xf86inputlibinput + pkgs.xorg.xf86videointel + pkgs.xorg.xf86videoati + pkgs.xorg.xf86videonouveau + pkgs.emulationstation + pkgs.home-manager + ]; + + users.users."${username}" = { + isNormalUser = true; + home = userhome; + extraGroups = [ "wheel" ]; + initialHashedPassword = "$y$j9T$mZVJ.MyA3PnxIzrUr4NbO.$wp6VqO0WphwynzPhw4Y3X57VcAaFla3sO9gTdV25xq8"; + }; + programs.bash.loginShellInit = + "startx ${pkgs.emulationstation}/bin/emulationstation"; + + hardware.opengl.enable = true; + hardware.opengl.driSupport = true; + services.xserver.enable = true; + services.xserver.displayManager.startx.enable = true; + services.xserver.libinput.enable = true; + services.getty.autologinUser = "arcade"; + + boot.loader.systemd-boot.enable = true; + + console.keyMap = "fr"; + services.openssh = lib.mkForce { enable = false; }; +}) diff --git a/emulationstation/configuration-files.nix b/emulationstation/configuration-files.nix new file mode 100644 index 0000000..acb40c6 --- /dev/null +++ b/emulationstation/configuration-files.nix @@ -0,0 +1,77 @@ +{ userhome, ... }: +let + romspath = "${userhome}/roms"; + themes = [ + { + name = "Arcade"; + theme = "arcade"; + } + { + name = "BeatThemAll"; + theme = "btmups"; + } + { + name = "BestJeuEver"; + theme = "bestjeuever"; + } + { + name = "Course"; + theme = "racing"; + } + { + name = "Kombat"; + theme = "kombat"; + } + { + name = "Plateforme"; + theme = "plateforme"; + } + { + name = "Shmup"; + theme = "shmups"; + } + { + name = "Sport"; + theme = "sports"; + } + { + name = "Versus"; + theme = "versus"; + } + ]; + + + system = { name, theme }: '' + + ${name} + ${name} + ${romspath}/${name} + .zip .nes .cue .rvz + bash %ROM% + snes + ${theme} + + ''; + + systems = themes: + let + list = builtins.foldl' (global: theme: global + (system theme)) "" themes; + in '' + + + ${list} + + ''; + +in { + environment.etc = { + "emulationstation/themes/hackens" = { + source = ./theme; + mode = "0755"; + }; + "emulationstation/es_systems.cfg" = { + text = systems themes; + mode = "0644"; + }; + }; +} diff --git a/emulationstation/roms b/emulationstation/roms new file mode 160000 index 0000000..746bb39 --- /dev/null +++ b/emulationstation/roms @@ -0,0 +1 @@ +Subproject commit 746bb3903f149670e51d22b1c8006188f47051ae diff --git a/emulationstation/theme b/emulationstation/theme new file mode 160000 index 0000000..77d82b8 --- /dev/null +++ b/emulationstation/theme @@ -0,0 +1 @@ +Subproject commit 77d82b8343e8b7b16cfd1c2ed014238b9189fc92 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..18860b4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703367386, + "narHash": "sha256-FMbm48UGrBfOWGt8+opuS+uLBLQlRfhiYXhHNcYMS5k=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "d5824a76bc6bb93d1dce9ebbbcb09a9b6abcc224", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.11", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701282334, + "narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "23.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f07e8a1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "Minimal NixOS installation media"; + + inputs = { + nixpkgs.url = "nixpkgs/23.11"; + home-manager.url = "github:nix-community/home-manager/release-23.11"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, home-manager, ... }@inputs: + let + username = "arcade"; + userhome = "/home/${username}"; + in { + nixosConfigurations = { + vm = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs username userhome; }; + modules = [ + home-manager.nixosModules.home-manager + { + home-manager.users.arcade = { ... }: { + home.username = username; + home.homeDirectory = userhome; + home.stateVersion = "23.11"; + home.file."roms".source = ./emulationstation/roms; + }; + } + ./configuration.nix + ./emulationstation/configuration-files.nix + "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix" + ]; + }; + }; + }; +}