Add NixOS integration documentation for updating cm-dashboard
Include step-by-step instructions for updating commit hash and rebuilding NixOS configuration when new cm-dashboard code is available.
This commit is contained in:
parent
f786d054f2
commit
9b6a504e48
91
README.md
91
README.md
@ -445,4 +445,93 @@ MIT License - see LICENSE file for details.
|
||||
4. Push to branch (`git push origin feature/amazing-feature`)
|
||||
5. Open Pull Request
|
||||
|
||||
For bugs and feature requests, please use GitHub Issues.
|
||||
For bugs and feature requests, please use GitHub Issues.
|
||||
|
||||
## NixOS Integration
|
||||
|
||||
### Updating cm-dashboard in NixOS Configuration
|
||||
|
||||
When new code is pushed to the cm-dashboard repository, follow these steps to update the NixOS configuration:
|
||||
|
||||
#### 1. Get the Latest Commit Hash
|
||||
```bash
|
||||
# Get the latest commit from the API
|
||||
curl -s "https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/commits?sha=main&limit=1" | head -20
|
||||
|
||||
# Or use git
|
||||
git log --oneline -1
|
||||
```
|
||||
|
||||
#### 2. Update the NixOS Configuration
|
||||
Edit `hosts/common/cm-dashboard.nix` and update the `rev` field:
|
||||
```nix
|
||||
src = pkgs.fetchFromGitea {
|
||||
domain = "gitea.cmtec.se";
|
||||
owner = "cm";
|
||||
repo = "cm-dashboard";
|
||||
rev = "f786d054f2ece80823f85e46933857af96e241b2"; # Update this
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # Reset temporarily
|
||||
};
|
||||
```
|
||||
|
||||
#### 3. Get the Correct Hash
|
||||
Build with placeholder hash to get the actual hash:
|
||||
```bash
|
||||
nix-build --no-out-link -E 'with import <nixpkgs> {}; fetchFromGitea {
|
||||
domain = "gitea.cmtec.se";
|
||||
owner = "cm";
|
||||
repo = "cm-dashboard";
|
||||
rev = "YOUR_COMMIT_HASH";
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
}' 2>&1 | grep "got:"
|
||||
```
|
||||
|
||||
#### 4. Update the Hash
|
||||
Replace the placeholder with the correct hash:
|
||||
```nix
|
||||
hash = "sha256-vjy+j91iDCHUf0RE43anK4WZ+rKcyohP/3SykwZGof8="; # Use actual hash
|
||||
```
|
||||
|
||||
#### 5. Update Cargo Dependencies (if needed)
|
||||
If Cargo.lock has changed, you may need to update `cargoHash`:
|
||||
```bash
|
||||
# Build to get cargo hash error
|
||||
nix-build --no-out-link --expr 'with import <nixpkgs> {}; rustPlatform.buildRustPackage rec {
|
||||
pname = "cm-dashboard";
|
||||
version = "0.1.0";
|
||||
src = fetchFromGitea {
|
||||
domain = "gitea.cmtec.se";
|
||||
owner = "cm";
|
||||
repo = "cm-dashboard";
|
||||
rev = "YOUR_COMMIT_HASH";
|
||||
hash = "YOUR_SOURCE_HASH";
|
||||
};
|
||||
cargoHash = "";
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ openssl ];
|
||||
buildAndTestSubdir = ".";
|
||||
cargoBuildFlags = [ "--workspace" ];
|
||||
}' 2>&1 | grep "got:"
|
||||
```
|
||||
|
||||
Then update `cargoHash` in the configuration.
|
||||
|
||||
#### 6. Commit the Changes
|
||||
```bash
|
||||
git add hosts/common/cm-dashboard.nix
|
||||
git commit -m "Update cm-dashboard to latest version"
|
||||
git push
|
||||
```
|
||||
|
||||
### Example Update Process
|
||||
```bash
|
||||
# 1. Get latest commit
|
||||
LATEST_COMMIT=$(curl -s "https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/commits?sha=main&limit=1" | grep '"sha"' | head -1 | cut -d'"' -f4)
|
||||
|
||||
# 2. Get source hash
|
||||
SOURCE_HASH=$(nix-build --no-out-link -E "with import <nixpkgs> {}; fetchFromGitea { domain = \"gitea.cmtec.se\"; owner = \"cm\"; repo = \"cm-dashboard\"; rev = \"$LATEST_COMMIT\"; hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"; }" 2>&1 | grep "got:" | cut -d' ' -f12)
|
||||
|
||||
# 3. Update configuration and commit
|
||||
echo "Latest commit: $LATEST_COMMIT"
|
||||
echo "Source hash: $SOURCE_HASH"
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user