Skip to content

Commit b57e1b3

Browse files
committed
feat: rewrite nix part
Signed-off-by: kaeeraa <kaeeraa@nebula-nook.ru>
1 parent 366dec6 commit b57e1b3

6 files changed

Lines changed: 278 additions & 297 deletions

File tree

flake.lock

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 55 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,104 +15,82 @@
1515
};
1616

1717
inputs = {
18-
nixpkgs = {
19-
url = "github:NixOS/nixpkgs/nixos-unstable";
20-
};
21-
22-
nix-filter = {
23-
url = "github:numtide/nix-filter";
24-
};
25-
18+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
19+
nix-filter.url = "github:numtide/nix-filter";
2620
libnbtplusplus = {
2721
url = "github:FreesmTeam/libnbtplusplus";
2822
flake = false;
2923
};
30-
31-
flake-compat = {
32-
url = "github:edolstra/flake-compat";
33-
flake = false;
34-
};
3524
};
3625

3726
outputs = {
3827
self,
3928
nixpkgs,
40-
libnbtplusplus,
4129
nix-filter,
30+
libnbtplusplus,
4231
...
4332
}: let
44-
inherit (nixpkgs) lib;
45-
systems = lib.systems.flakeExposed;
46-
forAllSystems = lib.genAttrs systems;
47-
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
33+
systems = [
34+
"x86_64-linux"
35+
"aarch64-linux"
36+
"x86_64-darwin"
37+
"aarch64-darwin"
38+
];
39+
40+
forEachSystem = nixpkgs.lib.genAttrs systems;
4841
in {
49-
formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra);
50-
devShells = forAllSystems (
51-
system: let
52-
pkgs = nixpkgsFor.${system};
53-
in {
54-
default = pkgs.mkShell {
55-
inputsFrom = [
56-
self.packages.${system}.freesmlauncher-unwrapped
57-
];
58-
buildInputs = [
59-
pkgs.ccache
60-
pkgs.ninja
61-
];
62-
shellHook = ''
63-
# https://discourse.nixos.org/t/qt-development-environment-on-a-flake-system/23707/5
64-
setQtEnvironment=$(mktemp)
65-
random=$(openssl rand -base64 20 | sed "s/[^a-zA-Z0-9]//g")
66-
makeWrapper "$(type -p sh)" "$setQtEnvironment" "''${qtWrapperArgs[@]}" --argv0 "$random"
67-
sed "/$random/d" -i "$setQtEnvironment"
68-
source "$setQtEnvironment"
69-
'';
70-
};
71-
}
72-
);
42+
overlays.default = final: prev: {
43+
freesmlauncher-unwrapped = final.callPackage ./nix/unwrapped.nix {
44+
inherit nix-filter libnbtplusplus self;
45+
};
46+
47+
freesmlauncher = final.callPackage ./nix/wrapper.nix;
48+
};
7349

74-
overlays = {
75-
default = final: prev: {
76-
freesmlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
77-
inherit
78-
libnbtplusplus
79-
nix-filter
80-
self
81-
;
82-
};
50+
packages = forEachSystem (system: let
51+
pkgs = import nixpkgs {inherit system;};
8352

84-
freesmlauncher = final.callPackage ./nix/wrapper.nix {};
53+
freesmlauncher-unwrapped = pkgs.callPackage ./nix/unwrapped.nix {
54+
inherit nix-filter libnbtplusplus self;
55+
};
56+
57+
freesmlauncher = pkgs.callPackage ./nix/wrapper.nix {
58+
inherit freesmlauncher-unwrapped;
8559
};
86-
};
8760

88-
packages = forAllSystems (
89-
system: let
90-
pkgs = nixpkgsFor.${system};
61+
freesmlauncher-unwrapped-debug = freesmlauncher-unwrapped.overrideAttrs {
62+
cmakeBuildType = "Debug";
63+
dontStrip = true;
64+
};
9165

92-
freesmPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs);
66+
freesmlauncher-debug = pkgs.callPackage ./nix/wrapper.nix {
67+
freesmlauncher-unwrapped = freesmlauncher-unwrapped-debug;
68+
};
69+
in {
70+
inherit freesmlauncher freesmlauncher-unwrapped freesmlauncher-debug freesmlauncher-unwrapped-debug;
9371

94-
packages = {
95-
inherit (freesmPackages) freesmlauncher-unwrapped freesmlauncher;
96-
default = freesmPackages.freesmlauncher;
97-
};
98-
in
99-
lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages
100-
);
72+
default = freesmlauncher;
73+
});
10174

102-
legacyPackages = forAllSystems (
103-
system: let
104-
freesmPackages = self.packages.${system};
105-
legacyPackages = self.legacyPackages.${system};
106-
in {
107-
freesmlauncher-debug = freesmPackages.freesmlauncher.override {
108-
freesmlauncher-unwrapped = legacyPackages.freesmlauncher-unwrapped-debug;
109-
};
75+
devShells = forEachSystem (system: let
76+
pkgs = import nixpkgs {
77+
inherit system;
78+
overlays = [self.overlays.default];
79+
};
80+
in {
81+
default = pkgs.mkShell {
82+
inputsFrom = [pkgs.freesmlauncher-unwrapped];
83+
84+
packages = with pkgs; [
85+
ccache
86+
ninja
87+
];
88+
};
89+
});
11090

111-
freesmlauncher-unwrapped-debug = freesmPackages.freesmlauncher-unwrapped.overrideAttrs {
112-
cmakeBuildType = "Debug";
113-
dontStrip = true;
114-
};
115-
}
91+
formatter = forEachSystem (
92+
system:
93+
(import nixpkgs {inherit system;}).alejandra
11694
);
11795
};
11896
}

nix/README.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,53 @@
77
88
---
99

10-
### <div align="center"> Using on NixOS / Nixpkgs </div>
10+
# Running and installing on NixOS
1111

12-
Currently, **Freesm** isn't in `nixpkgs` (yet?). To use it, you'll need to add it in your `flake.nix`:
12+
This article covers how to run or/and install **FreesmLauncher** on NixOS:
13+
14+
## <div align="center"> Run without installing </div>
15+
16+
```shell
17+
nix run github:FreesmTeam/FreesmLauncher#freesmlauncher
18+
```
19+
20+
## <div align="center"> Installing </div>
21+
22+
To use it, you'll need to add it in your `flake.nix`:
1323

1424
```nix
1525
{
1626
inputs = {
27+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
1728
freesmlauncher = {
1829
url = "github:FreesmTeam/FreesmLauncher";
19-
inputs = {
20-
nixpkgs = {
21-
follows = "nixpkgs";
22-
};
23-
};
30+
inputs.nixpkgs.follows = "nixpkgs";
2431
};
2532
};
26-
outputs = {
27-
self,
28-
nixpkgs,
29-
home-manager,
30-
freesmlauncher,
31-
...
32-
} @ inputs :
33-
... # rest of flake.
33+
outputs = {self, nixpkgs, freesmlauncher, ...}: ...
34+
}
35+
```
36+
37+
### NixOS system configuration
38+
39+
```nix
40+
{ config, pkgs, system, ... }:
41+
42+
{
43+
environment.systemPackages = [
44+
freesmlauncher.packages.${system}.freesmlauncher
45+
];
3446
}
3547
```
3648

37-
After that, you can add freesmlauncher to environment.systemPackages, users.users.<>.packages, or home.packages.
49+
### Home Manager configuration
50+
51+
```nix
52+
{ config, pkgs, system, ... }:
53+
54+
{
55+
home.packages = [
56+
freesmlauncher.packages.${system}.freesmlauncher
57+
];
58+
}
59+
```

0 commit comments

Comments
 (0)